- 2 minutes to read

xpath2 formula function

Support for XPath 2.0 and some more complex XPath queries, for the less resource-intensive and limited XPath support, please review the xpath user guide

The xpath2 Formula function is used to extract unique values from data in XML format using XPath 2.0 based expressions.

Syntax

XML Content comes from any of the following sources:

Quick example

Below is a simple example using XML data and an xpath2 expression to extract data:

Input Expression Result
 <Root>
	<Ids>
		<Id>
			<Name>EmployeeID</Name>
			<Value>1337</Value>
		</Id>
		<Id>
			<Name>Company</Name>
			<Value>ACME</Value>
		</Id>		
	</Ids>	
</Root>
xpath2('/Root/Ids/Id[Name=''EmployeeID'']/Value',body)
1337
XML data from message body XPath expression (with a look behind) Unique values

Note

Do note that the Name expression is escaped using two single quotes (´´)

Features

  • Extract single or multiple unique values from Content.
  • Any and all XPath 2.0 expression as defined by W3C
  • Can be applied to any valid Content that returns XML data structure; review Formula user guide for a complete list of functions.

Warning

This plugin loads the entire message into RAM, so make sure to apply this function only on small messages.

Note

Compared to the simpler 'xpath' function, the 'xpath2' function uses more RAM and uses more CPU cycles to get the job done. Do test the 'xpath' function first and only use the 'xpath2' function when you really need to

How to use

To use the xpath2 function, the Content parameter must contain a valid XML data structure (otherwise it will fail and you will end up with no or garbage result).

First, you must configure the Search Field Expressions to use the Formula plugin:

  • Input a proper XML Content

    Message Body or Message Context

  • Select Formula as the expression type plugin
  • Write down the XPath 2.0 expression to use in the 'Expression' text area using the xpath2 function

Example

Next Step

How to Add or manage Search Fields
How to Add or manage Log Views

Expression Type Plugins are used in Search Fields