XPath
ThexPath
helper can be used to extract values or sub documents via an XPath 1.0 expression from an XML string.
Most commonly this is used to extract values from the request body.
For example, given a request body of:
<inner>Stuff</inner>
:
Extracting attributes
XPath also permits extraction of attributes e.g. for a request body of:SOAP XPath
As a convenience thesoapXPath
helper also exists for extracting values from SOAP bodies e.g. for the SOAP document:
Iterating over XML elements
ThexPath
helper returns “one or many” collections results, which can either
be printed directly, or passed to further helpers such as each
or join
.
For instance, given a request body of the form:
XML element attributes
Elements in the collection returned byxPath
have the following properties:
text
: The text content of the element.
name
: The element’s name.
attributes
: A map of attribute names and values e.g. given an XML element has
been selected:
Formatting XML
TheformatXml
helper allows you to output XML in either a pretty or a compact format. The default is pretty: