The XPath Expression Type plugin can be used to find one or more unique values from elements and attributes in an XML document.
In order to extract values from messages with payload you must configure the following properties on a selected Search Field:
- Select the XPath Expression Type Plugin
- Enter a valid XPath in the Expression text box
- Select Message Type (The Logging Service applies the Expression on messages of that Message Type)
- Global - Applies the Expression on ALL messages (use with caution!!!). Global forces the Optional setting
- Optional - Does not mark the Event as processed with Warnings if value could not be extracted.
This default extractor uses a high performance read-only fast forward only stream reader. Based on Microsoft's XPathReader
The XPathReader provides the ability to perform XPath over XML documents in a streaming manner
The XPathReader provides the ability to filter and process large XML documents in an efficient manner using an XPath-aware XmlReader. With the XPathReader, one can sequentially process a large document and extract an identified sub-tree matched by an XPath expression
Not all types of XPaths can be evaluated using this XPath extractor, due to its forward only stream reader.
To extract order id(s) from the message type
Common.Schemas/Nodinite/1.0#Orders you can use the following valid expression
Orders/Order/Id. This expression extracts the values
<ns0:Orders xmlns:ns0="Common.Schemas/Nodinite/1.0"> <Order> <Id>101</Id> <Amount>1000</Amount> <City>Karlstad</City> </Order> <Order> <Id>102</Id> <Amount>10</Amount> <City>Stockholm</City> </Order> </ns0:Orders>
You can test an expression when configuring a Search Field in the Test Expression tab.
- Select the XPath expression type plugin
- Enter an Expression
- Enter payload
Values will be automatically extracted by the Logging Service and presented together with the evaluated processing state and the number of unique matches.
You can find some examples of allowed expressions to get you started in the following link: XPath examples