XPath Helper

Evaluates the XPath on an XML string.

The XPath Helper window allows the user to evaluate an XPath on a given XML string.

The XPath Helper contains the following sections:

  • XPath Expression

  • XPath Element selector

  • XPath Attribute Selector

  • XPath Input

  • Result

  • Error list

XPath Expression: XPath expressions are used to select nodes or sets of nodes in an XML input. Think of XPath expressions as similar to the paths you navigate in a computer file system. By following a path or steps, you can select specific nodes. In this section, you can enter your XPath expression.

The node is selected by following a path or steps. The most useful path expressions are listed below:

ExpressionDescription

nodename

Selects all the nodes with the name "nodename"

/

Selects from the root node

//

Selects nodes in the document from the current node that match the selection no matter where they are

.

Selects the current node

..

Selects the parent of the current node

@

Selects the attributes

Some sample path expressions and their result are provided below.

Path ExpressionResult

catalog

Selects all nodes with the name "catalog"

/catalog

Selects the root element catalog

Note: If the path starts with a slash ( / ) it always represents an absolute path to an element!

catalog/book

Selects all book elements that are children of catalog

//book

Selects all book elements no matter where they are in the document

catalog//book

Selects all book elements that are descendant of the bookstore element, no matter where they are under the bookstore element

//@id

Selects all attributes that are named id

XPath Input: This field is where you enter the XPath expression you want to evaluate on the provided XML string. It serves as the basis for selecting elements or attributes within the XML.

XPath Element Selector: Once you provide an XPath input, the XPath Element Selector section will populate with a list of elements present in the XML. You can select individual elements from this list. This helps you choose the specific elements you want to target with your XPath expression.

XPath Attribute Selector: Similarly, when you enter an XPath input, the XPath Attribute Selector section will display the attributes of the selected element, if any attributes exist. This allows you to select attributes associated with the chosen element.

Result: The Result section displays the output or evaluated result of the XPath expression on the given XML string. It shows the nodes or node sets that match the XPath expression you provided.

Error List: The Error List section displays the errors that occurred due to the given xml input. It shows the line and description of the specific errors in the Xml input section.

By using XPath expressions, you can effectively navigate and select specific elements or attributes within an XML structure. The XPath Helper window simplifies this process by providing an interface for evaluating XPath expressions and displaying the resulting output.

Last updated