UiPath Activities

The UiPath Activities Guide

Execute XPath

UiPath.Web.Activities.ExecuteXPath

Executes the specified XPath expression on a given XML document.

Properties

Input

  • ExistingXML - An XDocument variable containing the XML to be processed. Completing this field makes the XMLString field unusable. This field supports only XDocument variables.
  • XMLString - A string or string variable containing the XML to be processed. Completing this field makes the ExistingXML field unusable. This field supports only strings and string variables.
  • XPathExpression - A string or string variable that contains an XPath expression. This field supports only strings and string variables.

Misc

  • Private - If selected, the values of variables and arguments are no longer logged at Verbose level.

Common

  • DisplayName - The display name of the activity.

Output

  • Result - An Object variable containing the retrieved nodes or node-sets of the given XML. This field supports only Object variables.

Example of Using the Execute XPath Activity

The Execute XPath activity is used for reading and extracting data from .xml files.
To exemplify how to use this activity, we have created an example that uses the Execute XPath activity for extracting the name of a person from a .xml file.

This is how the automation process can be built:

  1. Open Studio and create a new Process.

Note:

Make sure to place the .xml file inside the project folder. For this example we used the XMLfiles.txt.

  1. Drag a Sequence to the Workflow Designer.
    • Create the following variables:
Variable Name
Variable Type
Default Value

XMLString

String

-

Result

Object

-

  1. Drag a Read Text File activity inside the sequence container.
    • In the Properties panel, add the name Read XML file in the DisplayName field.
    • Add the value "XMLfiles.txt" in the FileName field.
    • Add the variable XMLString in the Content field.
  2. Add an Execute XPath activity below the Read Text File activity.
    • In the Properties panel, add the variable XMLString in the XMLString field.
    • Add the value "string(/catalog/book/author/text()[1])" in the XPathExpression field. This expression extracts the text found in the author field from the xml file.
    • Add the variable Result in the Result field.
  3. Drag a Write Line activity below the Execute XPath activity.
    • Add the expression "Result: " + Result.ToString in the Text field.
  4. Run the process. The robot extracts the name of the author from the .xml file and displays it in the Output panel.
     
     
    Download example

Updated 2 months ago


Execute XPath


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.