Table of contents
Expand | ||
---|---|---|
| ||
|
...
Description
The tool is designed to validate data in XPath / JSONPath format and help in writing correct expressions for parsing data from XML and JSON documents.
...
The Beautify button allows you to automatically format the code and bring it to an easy-to-read format.
...
Basic XPath syntax.
Expression | Result |
---|---|
hostname | Selects all nodes named "node_name" |
/ | Selects from root node |
// | Selects nodes from the current node matching the selection, regardless of their location |
. | Selects the current node |
.. | Selects the parent of the current node |
@ | Selects attributes |
Special characters are used to search for unknown nodes:
Special character | Description |
---|---|
* | Matches any element node |
@* | Matches any attribute node |
node() | Matches any node of any type |
...
Basic JSONPath syntax.
Expression | Result |
---|---|
$ | Selects from root node |
.. | Parent operator |
... or [] | Descendant operator |
.. | Selects nodes from the current node matching the selection |
@ | Selects the current node |
?() | Applies a filter expression |
Examples:
Code Block | ||
---|---|---|
| ||
{ "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 }, { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 }, { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99 }, { "category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99 } ], "bicycle": { "color": "red", "price": 19.95 } } } |
XPath | JSONPath | Result |
|
| “author” elements of all “book” elements in “store” |
|
| all “author” elements |
|
| all content in "store" |
|
| the value of the price of the "price" element of all elements in the "store" |
|
| third element "book" |
|
| the last element "book" |
|
| the first 2 elements of "book" |
|
| filter all elements of “book” with value “isbn” |
|
| filter all “book” elements with “price” value less than 10 |
|
| all elements in the XML document. All members of the JSON structure. |