مُختبر ومحوّل تعبيرات XPath
مرشد
مُختبر ومحوّل تعبيرات XPath
Paste XML or HTML, type an XPath 1.0 expression, and instantly see which nodes match. The tester runs entirely in your browser, highlights matched fragments in the source, and shows a readable summary for node sets, strings, numbers, and booleans.
كيفية استخدام
- Paste your XML or HTML document into the source pane.
- Choose “Auto-detect”, “XML (strict)”, or “HTML (forgiving)” depending on how well-formed the markup is.
- Type an XPath expression or pick a ready-made example like
//book[@category='fiction']/title. - انقر تقييم. Matched nodes are highlighted inline and a list of results is printed below.
- Use the Copy or Download buttons to keep the result, or the Format button to pretty-print the source.
خصائص
- Native XPath 1.0 – يستخدم
document.evaluate()for the same engine the browser ships with, no network calls. - XML + HTML parsing – Strict XML mode for well-formed documents, forgiving HTML mode for scraped pages.
- Live highlighting – Matched elements, attributes, text nodes, and comments are highlighted directly in the source.
- Readable result panel – Prints one serialized match per entry, or the number/string/boolean value for aggregate queries.
- Match counter – Instant “N nodes matched” badge so you can tune selectors quickly.
- Example gallery – One-click XPath expressions for axes, predicates,
contains(),count()و، وlast(). - Pretty printer – One-click Format button for XML source.
- من جانب العميل فقط – Nothing leaves your machine; safe for private schemas and HTML snippets.
التعليمات
-
What is XPath used for?
XPath is a W3C query language for addressing parts of an XML or HTML document. It is the foundation of XSLT, XProc, many test-automation tools (Selenium, Playwright locators), web-scraping libraries, and SOAP/XML validation pipelines. It lets you describe a set of nodes using path expressions, predicates, and built-in functions.
-
How is XPath different from CSS selectors?
CSS selectors are limited to descendant, child, sibling, and attribute relationships and cannot traverse up the tree. XPath adds parent and ancestor axes, positional predicates, numeric comparisons, string functions like contains() and starts-with(), and the ability to select attributes and text nodes directly.
-
Which XPath version is supported?
The tester relies on the browser's built-in document.evaluate(), which implements XPath 1.0. XPath 2.0 and 3.1 features such as sequences, typed comparisons, and regex functions are not available in the browser natively.
-
Why might an expression work in a tool but fail in the browser?
Third-party libraries often implement XPath 2.0 or 3.1 which add sequence operators, type checks, and functions such as matches() and tokenize(). Browser engines stop at XPath 1.0, so any syntax that assumes newer features will throw an evaluation error when run natively.
-
How are HTML documents parsed compared to XML?
HTML parsing follows the HTML5 algorithm, which implicitly closes tags, lowercases element names, and accepts unquoted attributes. XML parsing is strict and rejects any well-formedness error. The tester auto-detects a DOCTYPE or root but you can force either mode when the heuristic guesses wrong.
تثبيت ملحقاتنا
أضف أدوات IO إلى متصفحك المفضل للوصول الفوري والبحث بشكل أسرع
恵 وصلت لوحة النتائج!
لوحة النتائج هي طريقة ممتعة لتتبع ألعابك، يتم تخزين جميع البيانات في متصفحك. المزيد من الميزات قريبا!
