Get multiple nodes action in XML

The Get multiple nodes action in the XML package enables you to retrieve the value of multiple nodes.

Settings

  • Enter the session name or select an existing variable used in the Start XML session action.
  • Enter the XPath expression to retrieve multiple nodes or select an existing variable.
  • In the Get each node field, select if you require the Text value, XPath expression, or Specific attribute name of each node.
    • Text value retrieves the exact value of the specific node element.
    • XPath expression refers to the path of the selected node in an XML document.
    • Specific attribute defines a property or the type of the element in a particular node. For example, lang is an attribute of the Locale element in a Cust_Details node. The output for lang attribute is displayed as es.

Example of how to retrieve the value of multiple nodes

You can create an XML file on your desktop. This example uses a sample XML with the following structure:
<Customer>
<Cust_Details>
	<custid city="Leon">A001</ custid>
<custname>XYZ Corp</custname>
<custzipcode>15639</custzipcode>
<country>Mexico</country>
<Locale lang=”es”> Spanish</Locale>
</Cust_Details>
</Customer>

To retrieve the value of multiple nodes from a customer details:

  1. Create and name the bot: XML_Bot.
  2. Start an XML session by using the XML > Start session action.
    1. In the Session name field, enter Default.
    2. In the Data Source field, choose File and select the Desktop file option. Click Browse to locate your XML file, for example: D:\userdefined path\xml sample.xml.
  3. Double-click or drag the Get multiple nodes action to retrieve the value of multiple nodes.
    1. In the Session name field, enter Default.
    2. In the XPath Expression field enter //Customer/Cust_Details/custid.
    3. In the Get each node field, select from the following options and print the output in the message box.
      • Text value
      • XPath expression
      • Specific attribute name of each node, If you select this option then enter the attribute city in the text box.
    4. In the Assign the output to variable (optional) field, select TableXMLNodes.
  4. Double-click or drag the Message box to print the values and enter $TableXMLNodes[0][0]$ in the Enter the message to display field.
  5. Click Save and then click Run.
The values retrieved from each node are as follows:
  • Text value: A001
  • XPath expression: /Customer/Cust_Details/custid
  • Specific attribute name of each node: Leon