Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

XPathJSONPathDescription
/$The base node in the object.
.@The current object in the node path.
/. or []Accessing a child node, or specific child node
..n/aAccessing the parent of the current node.
//..Recursive child decent.
**Wildcard operator to access any node.
@n/aAccessing an attribute.
[][]Accessing an element within a list of nodes.
|[,]Union of two sets of nodes.
n/a[start:end:step]Accessing elements as a slice of a set of elements.
[]?()Accessing nodes with a filter applied.

...

Listed below is an example response in JSON and XML.

 

Code Block
languagejs

...

...

{ 
  "messages": {
    "staging": [ 
      { 
        "category": "information",
        "message" : "Building..."
      },
      { 
        "category": "information",
        "message" : "Testing..."
      },
      { 
        "category": "information",
        "message" : "Completed!"
      }
    ],
    "production": [
      { 
        "category": "information",
        "message" : "Building..."
      },
      { 
        "category": "error",
        "message" : "Build Failed!"
      }
    ]
  }
}

 

 

Code Block
languagejs
<?xml version="1.0" encoding="UTF-8" ?>
<messages>
  <staging>
    <category>information</category>
    <message>Building...</message>
  </staging>
  <staging>
    <category>information</category>
    <message>Testing...</message>
  </staging>
  <staging>
    <category>information</category>
    <message>Completed!</message>
  </staging>
  <production>
    <category>information</category>
    <message>Building...</message>
  </production>
  <production>
    <category>error</category>
    <message>Build Failed!</message>
  </production>
</messages>

 

XPathJSONPathResult
/store/book/author$.store.book[*].authorthe authors of all books in the store
//author$..authorall authors
/store/*$.store.*all things in store, which are some books and a red bicycle.
/store//price$.store..pricethe price of everything in the store.
//book[3]$..book[2]the third book
//book[last()]$..book[(@.length-1)]
$..book[-1:]
the last book in order.
//book[position()<3]$..book[0,1]
$..book[:2]
the first two books
//book[isbn]$..book[?(@.isbn)]filter all books with isbn number
//book[price<10]$..book[?(@.price<10)]filter all books cheapier than 10
//*$..*all Elements in XML document. All members of JSON structure.

...