XML Data Source

The XML data source fetches data from a property containing XML using the XPath expression. The data source parses the input XML content with XPath and populates the specified properties with the parsed values.

Important

ReadyAPI cannot parse XML documents that contain the byte order mark (BOM) character.

You can use data sources of the XML type in the Data Source test step in functional tests. They are not available in virtual services.

Important

In this topic, we focus on how to configure the XML data source. We assume you are already familiar with data-driven testing and how to configure a data-driven loop. Otherwise, please read Basic Concepts of Data-Driven Testing, or complete some of our tutorials before you continue.

Configuration

The XML data source

The following example demonstrates how to configure an XML data source:

In the Source Step drop-down list, specify a test step whose property contains XML data. Specify this property in the Source Property drop-down list.

For example, you can specify a SOAP Request test step, the response to which contains XML data:

xml-example-specify-property.png

In Row XPath, specify an XPath expression that returns a set of elements for iteration.

Assume you have the following XML data:

To get a list of books, specify the following XPath expression:

//store[1]/books[1]/book

You can specify the expression manually or click Declare button and select the needed element by using the Select Row Path dialog.

Important

The Select Row Path dialog adds a predicate to the XPath. Remove it to select all the sibling elements.

Configuring XML data source: Specify Row XPath
  1. Click add.png to add a new property.

    ReadyAPI will add a new column path to the list.

  2. If the name of the added property is the same as the name of the desired child element, most likely, there is no need to customize the added XPath. Otherwise, perform the following steps to modify the XPath:

    • Select the added column path in the list.

    • Specify the XPath expression that returns the desired element. Note that ReadyAPI will apply this expression to the set of elements returned by the Row XPath expression. For example, to get the price/usd element from the XPath data above, specify the following XPath expression:

      price[1]/usd[1]

      To specify the XPath expression, click Declare button to use the Select Column XPath dialog:

      Configuring XML data source: Specify Column XPath

      You can also click Edit and specify the expression manually.

  3. Repeat the first two steps to add other properties.

  4. Click run.png to test the data source:

    Configuring XML data source: Run data source

See Also

Publication date: