XPath Testing Tool

XML/HTML Code

XPath Expression

Query Results

0 results
Please enter an XPath expression and execute the query

Common XPath Expression References

Basic Selection

  • /bookstore - Select Root Element
  • //book - Select All book Elements
  • /bookstore/book - Select book Elements Under bookstore
  • //book/title - Select title of All book Elements

Attribute Selection

  • //book[@category] - Books with a category attribute
  • //book[@category='web'] - Books where category is 'web'
  • //@lang - Select all lang attributes
  • //title[@lang='en'] - Titles where lang is 'en'

Position Selection

  • //book[1] - First book element
  • //book[last()] - Last book element
  • //book[position()<3] - First two book elements
  • //book[price>35] - Books with price greater than 35

Wildcard

  • //* - Select all elements
  • //@* - Select all attributes
  • //title[@*] - Titles with any attribute
  • //book/* - All child elements under book

About XPath:

XPath (XML Path Language) is a language for locating information in XML and HTML documents. It uses path expressions to select nodes or node sets in a document and is widely used in data extraction, web scraping, automated testing, and more. XPath supports various types of expressions, including absolute paths, relative paths, attribute selection, and conditional filtering, making it powerful and flexible. This tool supports standard XPath 1.0 syntax for testing and validating XPath expressions.