Description:
This step fetches a value by using the 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 the "updateVariables" step to configure its "Settings" properties. Provide a name to the step.
- Click 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.
- The XML used in the example is included below
<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 measures the workflow progress and the percent complete. This is achieved by configuring the step state and percent fields individually, as shown in the images below. Configure the “Logging” using the following properties.
- Click the "getXPathValue" step to configure its "Settings" properties. Give the step a name.
- Click the "getXPathValue" step to configure its "Advanced" properties. Then, give the step a name.
- The “Logging” setting configuration is necessary for documentation and also measures the workflow progress and the percent complete. This is achieved 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 |
Definition Sample:
You may download the sample definition(s) from the link here and later import it (drag-drop) to your FlowWright Process Definition (XML file) or Form Definition (HTML file) page.
NOTE: Please verify and complete the process steps for any missing configurations, such as file path references and database connections after import. Then, save the definition to confirm the changes.