# XPath Tester Online - CSS Selector Tester & Generator

> Test XPath 1.0 and CSS selectors on XML or HTML: live highlighting, namespace prefixes, function results and shortest unique selectors for any clicked node.

- URL: https://qilingtools.com/en/xpath-tester
- Category: Developer Tools (https://qilingtools.com/en/dev)
- Tags: [Developer](https://qilingtools.com/en/tags/dev), [Frontend](https://qilingtools.com/en/tags/frontend)
- Last updated: 2026-10-26
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

Scrapers, end-to-end tests and XML config work all mean tweaking an XPath or CSS selector until it hits exactly the right nodes. Paste XML or HTML (the type is detected automatically, or switch it yourself) and type an expression to see results live: matched elements, attributes and text nodes are highlighted in a pretty-printed source view, and a list shows each match’s absolute path, attributes and text. XPath runs on the browser’s built-in XPath 1.0 engine, so besides node sets you get the number, string or boolean result of functions such as count(), sum(), string() and boolean(). Documents with a default namespace — Atom, SVG, SOAP, Maven pom.xml — need prefixes in XPath 1.0, so the tool collects every namespace declaration and assigns an ns prefix to the default one; you can add or edit mappings too. It also works the other way round: click any element, attribute or text in the source view and you get several verified XPath and CSS selectors that match only that node, preferring stable hooks such as ids, attributes and text, shortest first, ready to copy or drop back into the query box. Includes an XPath and CSS cheat sheet and three sample documents. Everything is parsed locally in your browser; nothing is uploaded.

## How to use

1. Paste XML or HTML, or load an example
2. Pick XPath or CSS, type an expression and check the highlights and match list; use prefixes for default namespaces
3. Click a node in the source view and copy the generated unique XPath / CSS selector

## Features

- XPath 1.0 and CSS selectors (including :has() and :nth-of-type)
- All matches highlighted in a formatted source view
- Number / string / boolean function results
- Automatic namespace detection with editable prefixes
- Shortest unique XPath and CSS selector for any clicked node
- Match list with path, attributes and text
- Auto-detects XML vs HTML and reports parse errors
- Clickable XPath / CSS cheat sheet

## FAQ

### Why doesn’t //entry match anything in my Atom or SVG file?

Those documents declare a default namespace with xmlns="…", and in XPath 1.0 an unprefixed name only matches elements with no namespace. Use the prefix the tool assigns, e.g. //ns:entry/ns:title, or ignore namespaces with //*[local-name()='entry']. CSS selectors don’t have this restriction.

### How reliable are the generated selectors?

Every candidate is actually run against the current document and only shown if it matches the clicked node and nothing else. The tool prefers ids, name, class, data-* attributes or short text, then anchors on the nearest uniquely identifiable ancestor, and only falls back to an indexed absolute path. Selectors can still break when the page structure changes — indexed paths are the most fragile.

### Is XPath 2.0 or 3.0 supported?

No. Browsers only ship XPath 1.0, so 2.0+ functions such as matches(), lower-case() and sequence expressions aren’t available. The common ones — contains(), starts-with(), normalize-space(), translate(), count(), sum(), position(), last() — and all axes (ancestor, following-sibling and so on) work.

### Why do HTML paths start with /html/body?

When browsers parse HTML they add missing <html>, <head> and <body> elements and lowercase tag names. That matches the DOM seen by Chrome DevTools, Selenium and Playwright, so the generated selectors work there directly. Switch the document type to XML if you need the markup parsed exactly as written (it must be well-formed).

## Related tools

- [JSON Formatter](https://qilingtools.com/en/json): Free online JSON formatter: beautify or minify, validate with the exact line and column of any error, browse a collapsible tree, sort keys and escape strings.
- [Base64 Encode/Decode](https://qilingtools.com/en/base64): Free online Base64 encoder and decoder: UTF-8 safe, optional URL-safe variant, convert text to Base64 and back in real time. Processed locally, never uploaded.
- [URL Encode/Decode](https://qilingtools.com/en/url-encode): Free online URL encoder and decoder with encodeURIComponent and encodeURI modes. Escapes Chinese, spaces and special characters. Real-time and local, no upload.
- [JWT Decoder](https://qilingtools.com/en/jwt): Free online JWT decoder: decode the header and payload of a JSON Web Token, show expiry and issued-at times, all locally without uploading the token.
- [Timestamp Converter](https://qilingtools.com/en/timestamp): Free online Unix timestamp converter: convert timestamps and dates, auto-detect seconds or milliseconds, and show local, UTC, ISO 8601 and relative time.
- [Hash / Checksum](https://qilingtools.com/en/hash): Free online hash calculator: SHA-1, SHA-256, SHA-384 and SHA-512 of text or any file through the browser crypto API. Files never leave your device.
- [UUID Generator](https://qilingtools.com/en/uuid): Free online UUID generator: create RFC 4122 UUID v4 in bulk with a cryptographic RNG. Options for uppercase, no hyphens and braces, with one-click copy.
- [Base Converter](https://qilingtools.com/en/base-convert): Free online number base converter: convert between binary, octal, decimal, hexadecimal and any base 2–36. Uses BigInt for huge integers, computed locally.
