Testing XPath expressions
Use the XPath Evaluator to test XPath expressions against test XML documents.
To bring up the XPath Evaluator window,
select option from the Studio toolbar
menu.
You can use the XPath Evaluator to test XPath expressions
against XML files. You can edit the default XPath expressions, generated
in the following panes:
- In the Configure panes of the For Each and Split activities, an XPath expression is generated to define the recurring element. You can edit the default XPath expression displayed in the Element Name field.
- In the Configure panes of the While Loop and If..Then activities, an XPath expression is generated in the Expression Builder to define the conditions. You can edit the default XPath expression displayed clicking Advanced.
Note: XPath 2.0 is supported.
The following table describes the functionality of the XPath
Evaluator dialog box.
Field | Name Description |
---|---|
File | Specifies the directory location of the selected test XML file. Select the down arrow to select from the set of previously loaded XML files. |
Browse.. | Click Browse... to load the contents of the XML file from the file system. |
Load Source | A graphical representation of the source XML elements to test against. Selecting a node in this text box generates an XPath expression that finds all occurrences of this element when this XPath expression is evaluated against the specified XML data. |
Generated XPath Expression | XPath expression that is generated when an XML element is selected in the Load Source text box. |
Copy | Copy the XPath Expression from the Generated XPath Expression field to the XPath Expression field. |
XPath Expression | Specifies the XPath Expression used to evaluate or test against the XML data. |
Run | Select Run to evaluate the XPath expression against the source XML test data. The results of the evaluation are displayed in the text box on the right side of the pane. |
To evaluate an XPath expression complete the following
steps:
- Select the Studio toolbar menu. The XPath Evaluator window opens. option from the
- Click Browse... to load a test XML file from the file system. A graphical representation of the text XML elements shows in the Load Source text box.
- To specify an XPath expression, choose from one of the following
options:
- Enter an XPath expression directly into the XPath Expression field.
- Select an XML element in the Load Source text box and click Copy to copy the XPath expression from the Generated XPath Expression field to the XPath Expression field.
- Click Run. The result of running the XML
data against the XPath expression is displayed in the right bottom
pane. The following types can be returned:
- number —the value of the number is returned in the Value field
as shown in the following figure:
- boolean —the value of the boolean is returned in the Value
field as shown in the following figure:
- Node Set —the XML elements that match those displayed in
the XPath expression, the Value field is blank,
and the number of matching XML elements is reported as shown in the
following figure:
- string —the value of the boolean is returned in the Value field
as shown in the following figure:
- number —the value of the number is returned in the Value field
as shown in the following figure: