XPath Tester
XPath tester validates expressions online with node path details for crawler rule debugging and XML/HTML parsing workflows.
Match Results
No matches found
Enter XML/HTML and an XPath expression to see matched results
Result Details
Enter XPath and markup content to inspect node details
Quick Templates
XPath Tester Guide
XPath tester validates expressions against XML or HTML documents and helps inspect matched node paths, attributes, and text nodes for crawler rules, payload parsing, and frontend automation selectors.
XPath Basics
XPath selects nodes from tree-structured documents with path expressions. Use absolute paths for fixed structures and relative paths for flexible matching.
Absolute Path
/html/body/divStarts from the root node, suitable for fixed document structures.
Relative Path
//div[@class='content']Matches nodes at any descendant level and is commonly used.
Common Syntax Reference
- `/`: select from root (absolute path)
- `//`: select at any descendant level (relative path)
- `@attr`: select attribute nodes
- `[1]`, `[last()]`: filter by position
- `contains()`, `starts-with()`: string matching functions
- `text()`: select text nodes
Practical Examples
- `//a[@href and contains(@class,'external')]`: select external links
- `//table//tr[position()>1]/td[1]`: extract first table cell while skipping header
- `//*[not(self::script) and not(self::style)]//text()`: extract visible text
XPath Axes
- `ancestor::`: select all ancestor nodes
- `descendant::`: select all descendant nodes
- `following-sibling::`: select following sibling nodes
- `preceding-sibling::`: select preceding sibling nodes
- `child::`: select child nodes
- `parent::`: select parent node