getXPathValue Step
Description:
Get a value from using XPath expression
Inputs
- xmlVariable - variable that holds the xml
- xPathExpression - xpath expression to use
- attributeName – name of the attribute
- variableToStoreValue - variable to store the value
- isExpression - evaluate xpath function
Returns
- True – True condition
- False – False condition
Usage:
Example:
Let’s build and execute the getXPathValueDef example.
- Create a new definition called “getXPathValueDef”
- Select the definition and click the “design” button
- Drag updateVariables, getXPathValue steps from the toolbox and connect the steps as shown above
- Define a variable/global to store the XML value and result after execution
- Click on the "updateVariables" step to configure its "Settings" properties. Provide a name to the step.
- Click on the "updateVariables" step to configure its "Advanced" properties. Provide the variable/global to store the XML value. Provide the XML value. Configure “Yes” if the value has an expression to evaluate.
- Sample XML value for reference
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="web">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="web">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
- The “Logging” setting configuration is necessary for documentation and also measure the workflow progress and the percent complete. This is acheived by configuring the step state and percent fields individually as shown in the images below. Configure the “Logging” using the following properties.
- Click on the "getXPathValue" step to configure its "Settings" properties. Provide a name to the step.
- Click on the "getXPathValue" step to configure its "Advanced" properties. Provide a name to the step.
- The “Logging” setting configuration is necessary for documentation and also measure the workflow progress and the percent complete. This is acheived by configuring the step state and percent fields individually as shown in the images below. Configure the “Logging” using the following properties.
- Save the process definition, create a new process instance and execute.
- Render the process instance. Click on the process step. The step should get the value from XPath.
- Click on the “getXPathValue” step to view the variables / properties information
- Some XPath expressions and the result of the expressions (for reference).
xPath expression | Result |
//bookstore/book[1] | Selects the first book item that is a child of the bookstore item |
//bookstore/book[last()] | Selects the last book item that is a child of the bookstore item |
//bookstore/book[last()-1] | Selects the second-to-last book item that is a child of the bookstore item |
//bookstore/book[position()<3] | Selects the first two book items that are children of the bookstore item |
//title[@lang] | Selects all the title elements that have an attribute named “lang” |
//title[@lang='en'] | Selects all the title elements that have a "lang" attribute with a value of "en" |
//bookstore/book[price>35.00] | Selects all the book elements of the bookstore element that have a price element with a value greater than 35.00 |
//bookstore/book[price>35.00]/title | Selects all the title elements of the book elements of the bookstore element that have a price element with a value greater than 35.00 |