DevToys Web Pro iconDevToys Web ProBlog
Rate us:
Try browser extension:

XPath Tester

No matches
Mode
XPath Expression

XML / HTML Input

  • Results

    No nodes matched the XPath expression.
    Technical details

    How the XPath Tester Works

    What the Tool Does

    The XPath Tester evaluates XPath expressions against XML or HTML documents and highlights the matched nodes in the source. You paste your XML/HTML document, enter an XPath expression, and instantly see all matching nodes with their content extracted. This provides immediate visual feedback for developing queries used in web scraping, XSLT transformations, and XML data extraction.

    Common Developer Use Cases

    Developers use XPath testers when building web scraping selectors (Scrapy, lxml), writing XSLT transformations, querying SOAP/XML API responses, or extracting data from configuration files like Maven POMs and Android manifests. QA engineers develop Selenium locators using XPath when CSS selectors are insufficient (e.g., selecting by text content or traversing upward). DevOps engineers query XML-based build and deployment configs.

    Data Formats, Types, or Variants

    XPath supports location paths (//book/title), predicates (//item[@price > 10]), axes (ancestor::, following-sibling::), functions (contains(), starts-with(), normalize-space(), count()), and union expressions (|). XPath 1.0 returns node-sets, strings, numbers, and booleans. XPath 2.0+ adds sequences, regular expressions, and date/time functions, though browser implementations typically support 1.0. Namespace-prefixed elements require namespace registration for correct matching.

    Common Pitfalls and Edge Cases

    The most common XPath mistake is forgetting about default namespaces — elements in a namespace will not match unprefixed paths even when no prefix appears in the source document. HTML parsed as XML is case-sensitive (DIV ≠ div), while HTML5 parsers normalize to lowercase. The '//' abbreviation searches all descendants and can be extremely slow on large documents; prefer absolute paths when structure is known. Browser XPath engines do not support XPath 2.0 functions like matches() for regex.

    When to Use This Tool vs Code

    Use this browser tool for rapid prototyping of XPath expressions against sample documents before embedding them in scraping or transformation code. For production XML processing, use dedicated libraries (lxml for Python, Saxon for Java) that support XPath 2.0/3.0, handle namespaces properly, and integrate with XSLT and XQuery pipelines for complex document transformations.