Get multiple nodes action in XML
- Updated: 2023/04/25
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 theLocale
element in aCust_Details
node. The output forlang
attribute is displayed ases
.
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:
- Create and name the bot: XML_Bot.
- Start an XML session by using the action.
- In the Session name field, enter Default.
- 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.
- Double-click or drag the Get multiple nodes
action to retrieve the value of multiple nodes.
- In the Session name field, enter Default.
- In the XPath Expression field enter //Customer/Cust_Details/custid.
- 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.
- In the Assign the output to variable (optional) field, select TableXMLNodes.
- Double-click or drag the Message box to print the values and enter $TableXMLNodes[0][0]$ in the Enter the message to display field.
- 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