Skip to main content

Read Data from XML

Description

Use this Activity to extract data from the input XML content/file based on the provided XPath.

Design Time Configuration

This Activity contains a design configuration similar to Multi Assign Activity.

You can either specify the file path of an XML file or provide the XML content as a literal string or through a variable of type string. To retrieve specific values from an XML file: Create a list of corresponding XPath expressions. Define variables to hold these values and map them to their respective XPath expressions. In the first column, enter the variable name and add the corresponding XPath in the second column.

note

Defining a variable to retrieve data of type key-value and a list of key-value pairs will work for only two data types, i.e., string and string object.

Retrieving Value from XML

Consider the following XML file; you can retrieve a list of books from the XML content below, as depicted by the screenshot below the content.

<?xml version="1.0" encoding="UTF-8"?>
<library>
<book>
<title>Introduction to Programming</title>
<author>John Smith</author>
<year>2020</year>
</book>
<book>
<title>Data Structures and Algorithms</title>
<author>Alice Johnson</author>
<year>2019</year>
</book>
<book>
<title>Web Development with HTML and CSS</title>
<author>David Brown</author>
<year>2021</year>
</book>
</library>

Read Data from XML

Properties

Input

  • Content/Path - Specify the XML file path or XML content to extract the information.

Misc

  • DisplayName – The display name of the Activity.
  • Private – If selected, the values of variables and arguments supplied will never be logged.

Optional

  • Continue On Error – It Specifies whether the automation should continue even when the Activity throws an error. If True, the Activity continues without throwing any exceptions. If False, the Activity throws an exception. The default value is False.
    note

    Catches no error if this Activity is present inside the Try-Catch block and the value of this property is True.

Example

Download Example

Read Data from XML