Understanding JSONPath and XPath
Up until now, we have always used the basic syntax to traverse JSON data and access certain elements and values within it. In this section, we will look at JSONPath and XPath, which offer more flexibility when dealing with JSON and XML respectively.
This is not meant as a reference but rather a demonstration of how these two approaches work. You are encouraged to learn more about these as they offer a lot of functionality in themselves!
Working with XPath
Let’s look at XPath first as JSONPath is loosely based on it.
XPath details
XPath is a language to parse XML structures. It considers an XML document as a node tree of elements, attributes, and text and can find XML parts in children and parent nodes. More information about XPath can be found here:
https://www.w3.org/TR/1999/REC-xpath-19991116/
We will use this XML structure within a Karate test scenario:
Scenario: Xpath * def data = ""...