DevToolBox免费
博客

XPath 在线测试器 — 免费评估 XPath 表达式

实时测试 XML 数据的 XPath 表达式。支持 XPath 1.0 函数、节点选择和属性查询。免费在线 XPath 评估器。

Common XPath Examples:

关于 XPath 测试器

XPath(XML 路径语言)是一种用于从 XML 文档中选择节点的查询语言。这个在线 XPath 测试器让您可以实时评估 XML 数据的 XPath 表达式。支持 XPath 1.0 函数,包括 text()、count()、contains() 等。适用于调试 XSLT 转换、网页抓取选择器和 XML 数据提取。

𝕏 Twitterin LinkedIn

💬 User Feedback

Have suggestions or found a bug? Leave a message and we'll get back to you.
0/2000

评价此工具

3.9 / 5 · 174 人评价

保持更新

获取每周开发技巧和新工具通知。

无垃圾邮件,随时退订。

Enjoy these free tools?

Buy Me a Coffee

How to Use XPath Tester

  1. Paste your XML document into the XML Input field
  2. Enter an XPath expression in the XPath Query field (e.g., //book/title)
  3. Click 'Evaluate XPath' to run the query against your XML
  4. View matching nodes, their values, and the total match count in the results panel
  5. Try the built-in XPath examples for common query patterns

Common Use Cases

  • Testing XPath expressions for web scraping and data extraction
  • Debugging XSLT transformations by validating XPath selectors
  • Querying XML configuration files (pom.xml, web.xml, AndroidManifest.xml)
  • Learning XPath syntax with real-time feedback on XML documents
  • Validating XPath locators for Selenium or Playwright test automation

Frequently Asked Questions

What is XPath and how does it work?
XPath (XML Path Language) is a query language for selecting nodes from XML documents. It uses path-like expressions to navigate the XML tree structure. For example, //book selects all book elements, and //book[@price>30] selects books with a price attribute greater than 30.
What is the difference between XPath and CSS selectors?
XPath can navigate both forward and backward in the XML/HTML tree and supports complex conditions, while CSS selectors only navigate downward. XPath is more powerful for XML querying, while CSS selectors are simpler and faster for HTML styling. XPath supports text content matching; CSS selectors do not.
How do I select elements by attribute in XPath?
Use the @ symbol to select attributes. For example: //div[@class='main'] selects div elements with class 'main', //input[@type='text'] selects text inputs, and //*[@id='header'] selects any element with id 'header'.
What is the difference between / and // in XPath?
A single slash (/) selects from the root or current node's direct children only. Double slash (//) selects matching nodes anywhere in the document regardless of depth. For example, /bookstore/book selects direct children, while //book selects all book elements at any level.
Can I use XPath to query HTML documents?
Yes. XPath works on both XML and well-formed HTML (XHTML). Most browsers support XPath queries via document.evaluate(). This tool accepts any valid XML input, including XHTML documents.
How do I test XPath expressions for Selenium?
Paste your page's HTML source into the XML Input field, then test your XPath locator expressions. This helps you validate selectors before using them in Selenium's find_element(By.XPATH, '...') or Playwright's page.locator('xpath=...') calls.
What XPath functions are supported?
This tool supports standard XPath 1.0 functions including: text(), contains(), starts-with(), string-length(), count(), sum(), position(), last(), not(), and boolean operators (and, or). These work for filtering and matching nodes.