About XPATH Tester
XPath Tester is an online tool to test your XPath expressions/queries against an XML file. It supports most of the XPath functions (string(), number(), name(), string-length() etc.) and does not limit you to working against nodes. It fully supports XML namespaces, but the declarations MUST be explicit and MUST be on the root XML element. You can include the XML item type (Attribute, Element, Text, etc.) as part of the output and allows you to better understand which parts were matched.
How to test XPATH expression against XML?
- To test your XPATH expression against XML add/ copy and paste the XML and XSD data into the input.
- You can also load the XML data from the url by clicking the button or load the XML data from the computer by clicking the button.
- Enter the appropriate XPATH query expression. Look into the below 'XPATH Query' expressions for your reference.
- Click the 'Test' button to parse your xml and get the output based on the xpath expression
|/||Select the document node|
|/root||Select the 'root' element|
|/root/celebritys/celebrity||Select all 'celebrity' elements that are direct children of the 'celebritys' element.|
|//foo:artist||Select all 'artist' elements regardless of their positions in the document.|
|//foo:artist/@id||Select the 'id' attributes of the 'artist' elements regardless of their positions in the document.|
|//celebrity/text()||Select the textual value of first 'celebrity' element.|
|//celebrity[last()]||Select the last 'celebrity' element.|
|//celebrity[position() < 3]||Select the first and second 'celebrity' elements using their position.|
|//celebrity[@id]||Select all 'celebrity' elements that have an 'id' attribute.|
|//celebrity[@id='3']||Select the 'celebrity' element with the 'id' attribute value of '3'.|
|//celebrity[@id<=3]||Select all 'celebrity' nodes with the 'id' attribute value lower or equal to '3'.|
|/root/foo:singers/*||Select all the children of the 'singers' node.|
|//*||Select all the elements in the document.|
|//celebrity|//foo:artist||Select all the 'celebrity' elements AND the 'artist' elements.|
|name(//*)||Select the name of the first element in the document.|
|number(//celebrity/@id)||Select the numeric value of the 'id' attribute of the first 'celebrity' element.|
|string(//celebrity/@id)||Select the string representation value of the 'id' attribute of the first 'celebrity' element.|
|string-length(//celebrity/text())||Select the length of the first 'celebrity' element's textual value.|
|local-name(//foo:artist)||Select the local name of the first 'artist' element, i.e. without the namespace.|
|count(//foo:artist)||Select the number of 'artist' elements.|
|sum(//foo:artist/@id)||Select the sum of the 'id' attributes of the 'artist' elements.|