# Detect and Analyze an XML File

> The following example explains how to use activities such as [Deserialize XML](https://docs.uipath.com/activities/other/latest/developer/deserialize-xml) or [Execute XPath](https://docs.uipath.com/activities/other/latest/developer/execute-x-path) for deserializing and analyzing a XML file. You can find these activities in the **UiPath.WebAPI.Activities** package.

The following example explains how to use activities such as [Deserialize XML](https://docs.uipath.com/activities/other/latest/developer/deserialize-xml) or [Execute XPath](https://docs.uipath.com/activities/other/latest/developer/execute-x-path) for deserializing and analyzing a XML file. You can find these activities in the **UiPath.WebAPI.Activities** package.

:::note
Download and extract the archive with the project in this example and copy the folder **MissingScreenshotSampleProject-ForTestPurposes** to your project folder.
:::

This is how the automation process can be built:

1. Open Studio and create a new **Process**.
2. Drag a **Sequence** container in the **Workflow Designer**.
   * Create the following variables:

     | Variable Name | Variable Type | Default Value |
     | --- | --- | --- |
     | `SelectedProjectPath` | **String** |  |
     | `WorkflowXMLString` | **String** |  |
     | `WorkflowXML` | **XDocument** |  |
     | `ScreenshotAttributes` | **Object** |  |
3. Add a **Select Folder** activity inside the **Sequence**.
   * In the **Properties** panel, add the variable `SelectedProjectPath` in the **SelectedFolder** field.
4. Add a **For Each** activity after the **Select Folder** activity.
   * Add the value `WorkflowFile` in the **ForEach** field.
   * Add the expression `Directory.GetFiles(SelectedProjectPath, "*.xaml", SearchOption.AllDirectories)` in the **Values** field.
5. Add a **Read Text File** in the **Body** container of the **For Each** activity.
   * Add the value `WorkflowFile` in the **FileName** field.
   * In the **Properties** panel, add the variable `WorkflowXMLString` in the **Content** field.
6. Add a **Deserialize XML** activity after the **Read Text File**.
   * Add the variable `WorkflowXMLString` in the **XMLString** field.
   * In the **Properties** panel, add the value `WorkflowXML` in the **XMLDocument** field.
7. Add an **Execute XPath** activity after the **Deserialize XML** activity.
   * Add the value `WorkflowXML` in the **Existing XML** field.
   * Add the expression `"//@InformativeScreenshot"` in the **XPath Expression** field.
   * In the **Properties** panel, add the variable `ScreenshotAttributes` in the **Result** field.
8. Add a **For Each** activity after the **Execute XPath** activity.
   * Add the value `Attribute` in the **ForEach** field.
   * Add the expression `CType(ScreenshotAttributes, IEnumerable).Cast(Of XAttribute)` in the **Values** field.
   * Select the **Body** container of the activity and create the following variable:

     | Variable Name | Variable Type | Default Value |
     | --- | --- | --- |
     | `ScreenshotFileExists` | **Boolean** |  |
9. Add a **Log Message** activity inside the **Body** container of the **For Each** activity.
   * Add the expression `"Looking for: " + SelectedProjectPath + "\.screenshots\" + Attribute.Value + ".png"` in the **Message** field.
10. Add a **Path Exists** activity after the **Log Message** activity.
    * Select the **File** option from the **Path File** drop-down list.
    * Add the expression `SelectedProjectPath + "\.screenshots\" + Attribute.Value + ".png"` in the **XPath Expression** field.
11. Add an **If** activity after the **Path Exists** activity.
    * Add the expression `Not ScreenshotFileExists` in the **Condition** field.
12. Add a **Log Message** activity inside the **Then** field of the **If** activity.
    * Select the **Warn** option from the **Level** drop-down list.
    * Add the expression `String.Format("Could not find the screenshot file {0}.png referenced by file {1}", Attribute.Value, WorkflowFile)` in the **Message** field.

      ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/developer-docs-image-185590-0bf91813-36474f55.webp)
13. Run the process. When prompted, select the **MissingScreenshotSampleProject-ForTestPurposes** folder. The XML workflow file in the folder is read and deserialized. Information about screenshots referenced in the XAML is used to identify and log found and missing screenshots in the folder.

[Here](https://docexamples.uipath.com/examples/Activities/Detect%20and%20Analyze%20an%20XDocument%20-%20Example.zip) you can download an example.
