Using XPATH to Read Elements/Attributes in Business Processes
XPath is used to navigate through elements and attributes in an XML document. There might be times we need to read/interroagate the XML data without a ruleset. XPATH functionailty gives us the ability to perform this process.
In the example below we will extract the attribute:lang value from the <title> element.
<?xml version="1.0" encoding="UTF-8"?>
<title lang="en">Harry Potter</title>
Business Process Set-up
Below we set-up 3 tasks to read the XML data and capture the attribute:lang value from the <title> element
XmlXpathQuery TaskIn the first task we are going to read the XML data from the Storage Node via XmlXpathQuery We will use the XPATH of /Book/title[@en](string literal) to read the example XML data. Once the data is captured, we will place the data into xmlArry (Array).
Once the data is in the array, we will retrieve the data in the first position of the array via GetArrayElement Task. In this case, it will be position 0 (zero). The result will be placed into xmlResule (object)
After the data is in an Object variable, we will use ConvertToString Task, to place the data into a string variable.
By: Sean Hoppe on