XPath Tester / Evaluator
To use this free online XPath tester paste your code into the editor on the left or upload using the options below.
What is this tool?
It is a simple online tool that you can use to test XPath expressions against your XML code. It supports features found in XPath 1.0 and 2.0.
To begin using this tester paste your XML into the editor on the left or use the options below to upload a file from your computer or a location on the internet.
You can then type your expressions in and click the "test" button to see the result in the editor on the right.
XML Code and Expression Examples
Below is XML code and a list of working XPath expressions to demonstrate how one could extract different elements of information from it.
<root xmlns:foo="http://www.foo.org" xmlns:bar="http://www.bar.org">
<actor id="1">Ted Levine</actor>
<actor id="2">Kathleen Quinlan</actor>
<actor id="3">Dan Byrd</actor>
<actor id="4">Emilie de Ravin</actor>
<actor id="5">Aaron Stanford</actor>
<actor id="6">Vinessa Shaw</actor>
<writer id="1">Wes Craven (based upon his film)</writer>
<writer id="2">Alexandre Aja (screenplay)</writer>
<director id="5">Alexandre Aja</director>
select all the elements in the document.
selects the "root" elements and all of its outer HTML
selects all of the "actor" elements contained directly within the "cast" element
select all "foo:crew" elements regardless of their positions in the document.
select the "id" attributes of the "crew" elements regardless of their positions in the document.
select the textual value of first "cast" element.
select the last "actor" element.
//actor[position() < 3]
select the first and second "actor" elements using their position.
select all 'actor' elements that have an "id" attribute.
select the "actor" element with the "id" attribute value of "2".
select all 'actor' nodes with the 'id' attribute value lower or equal to '3'.
select all the children of the "writers" node.
select the name of the first element in the document.
select the numeric value of the 'id' attribute of the first 'actor' element.
select the string representation value of the 'id' attribute of the first 'actor' element.
select the length of the first 'actor' element's textual value.
Select the number of 'writer' elements.