XPath Tester - Evaluator

The XPath Tester - Evaluator is an essential online tool designed for developers and data analysts who work with XML documents and need to test their XPath expressions. This free tool provides a straightforward interface to input XML data and XPath queries, allowing you to quickly evaluate and debug your expressions.

Key Features:
  • Instant Evaluation: Input your XML document and XPath expression to receive immediate results, streamlining your development process.
  • User-Friendly Interface: The intuitive design makes it easy for both beginners and experienced users to navigate and utilize the tool effectively.
  • Error Feedback: Receive clear error messages and suggestions if your XPath expression is invalid, enabling you to make necessary corrections.
  • Supports Multiple XPath Versions: Test expressions using XPath 1.0 and XPath 2.0, ensuring compatibility with various XML standards.
  • Test with Sample XML: Utilize built-in sample XML documents to quickly practice and learn XPath expressions without needing to upload your files.

Whether you're working with small XML snippets or large, complex documents, the XPath Tester - Evaluator tool simplifies the testing process, allowing you to develop accurate and efficient XPath queries. Enhance your XML data manipulation skills and streamline your workflow with this powerful online tool.

All of the following examples utilize this sample XML structure. For more information on XPath expressions, refer to W3Schools.com.

<catalog xmlns:music="http://www.music.org/" xmlns:movie="http://www.movie.org">
               <films>
                   <film id="1">Inception</film>
                   <film id="2">Interstellar</film>
                   <film id="3">Dunkirk</film>
               </films>
               <music:artists>
                   <music:artist id="4">Adele</music:artist>
                   <music:artist id="5">Beyoncé</music:artist>
                   <music:artist id="6">Ed Sheeran</music:artist>
               </music:artists>
           </catalog>
  1. Select the root node
    /
  2. Select the 'catalog' element
    /catalog
  3. Select all 'film' elements that are direct children of the 'films' element
    /catalog/films/film
  4. Select all 'artist' elements regardless of their position in the document
    //music:artist
  5. Select the 'id' attributes of the 'artist' elements regardless of their position in the document
    //music:artist/@id
  6. Select the textual value of the first 'film' element
    //film[1]/text()
  7. Select the last 'film' element
    //film[last()]
  8. Select the first and second 'film' elements using their position
    //film[position() < 3]
  9. Select all 'film' elements that have an 'id' attribute
    //film[@id]
  10. Select the 'film' element with the 'id' attribute value of '2'
    //film[@id='2']
  11. Select all 'film' nodes with the 'id' attribute value lower or equal to '2'
    //film[@id <= 2]
  12. Select all the children of the 'artists' node
    /catalog/music:artists/*
  13. Select all elements in the document
    //
  14. Select all the 'film' elements AND the 'artist' elements
    //film | //music:artist
  15. Select the name of the first element in the document
    name(//*[1])
  16. Select the numeric value of the 'id' attribute of the first 'film' element
    number(//film[1]/@id)
  17. Select the string representation value of the 'id' attribute of the first 'film' element
    string(//film[1]/@id)
  18. Select the length of the first 'film' element's textual value
    string-length(//film[1]/text())
  19. Select the local name of the first 'artist' element (without the namespace)
    local-name(//music:artist[1])
  20. Select the number of 'artist' elements
    count(//music:artist)
  21. Select the sum of the 'id' attributes of the 'artist' elements
    sum(//music:artist/@id)