Aller au contenu principal

XML / XPath Validator

The XML / XPath Validator lets you test XPath expressions against an XML document, format XML, and auto-generate XPath expressions from the cursor position.

:::info Screenshot needed — light/dark 📸 xml-xpath-validator-light.png and xml-xpath-validator-dark.png — Full view with XML document on left, XPath and results on right :::

Interface​

The tool uses a split-pane layout:

  • Left — XML Document editor (syntax-highlighted) with Load Example and Format Document buttons, and a live Path: display at the bottom
  • Right, top — XPath Expression input
  • Right, bottom — Evaluation Result editor
  • Bottom — Error message area and the Evaluate button

Live Path Display​

As you move the cursor through the XML document, the current XPath is displayed in real-time in the Path: bar at the bottom of the left pane. This is useful for discovering the path to a deeply nested element without manually counting indices.

Formatting XML​

Click Format Document (above the XML editor) to pretty-print the XML with proper indentation. If the XML is malformed, the message "There was an error in XML document, it cannot be formatted." appears in the bottom status area.

Evaluating XPath​

  1. Paste or type an XML document in the left editor
  2. Enter an XPath expression in the XPath Expression input (for example //book/title, or with a namespace: declare namespace ns="http://example.com/books"; //ns:book[ns:price > 10]/ns:title/text())
  3. Click Evaluate
  4. Results appear in the Evaluation Result editor

If the XPath matches nothing, the message "The given XML path does not bring any result." is shown. If the XPath raises an error, the specific error is displayed in the status area.

Generating XPath from Cursor Position​

Right-click anywhere in the XML document to access three context menu actions:

ActionBehavior
Show XPath from hereDisplays the generated XPath in a dialog
Copy XPath to ClipboardCopies the XPath to the clipboard
Use XPathInserts the generated XPath into the expression input

The XPath is generated based on the XML element at the cursor position, including element names and attribute filters where applicable.

remarque

The Load Example button pre-fills the editor with a sample bookstore XML document and a namespace-aware XPath expression. It disappears once you start editing the document.

See Also​