- 3 minutes to read

xpath formula function

Support for XPath 1.0, for xpath 2.0, please review the xpath2 user guide

The xpath Formula function is used to extract unique values from data in XML format using some XPath 1.0 based expressions.


XML Content comes from any of the following sources:

Quick example

Below is a simple example using XML data and an XPath expression to extract data: For other and advanced examples, please scroll down on this page to the Examples section.

Input Expression Result
XML data from message body xpath expression Unique values


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

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

How to use

To use the xpath 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 expression to use in the 'Expression' text area


Below are some common examples on how to use the xpath function.

Content from Message Body

In this example the data comes from the message body. The data is base64encoded and must be decoded into its XML representation before applying the XPath 1.0 expression to get the value of interest.


Input Expression Result
Base 64 encoded XML data from message body combined expression using the xpath method on the result from the base64decode expression Unique values

Content from Context Properties

In this example the data comes from the message context. The provided xpath expression gets the unique values of interest.


Input Expression Result
XML data from message context xpath expression Unique values

Contains based XPath example

In this example we get the value from a collection of attributes in some XML structure using the contains xpath method. The retreived value is then cleansed from its prefix (VATNO:).

Input Expression Result
  <Data Data="SENDERID:13"/>
  <Data Data="VATNO:SE19840410-1337"/>  
  <Data Data="RECEIVERID:37"/>  
replace('VATNO:', '',xpath('/Root/Data[contains(@Data, ''VATNO'')]/@Data',body))
XML data from message body combined expression using the replace method on the result from the xpath expression Unique values

Do note that the attribute used in the expression is escaped using 2 single quotes (´´)

Next Step

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

Expression Type Plugins are used in Search Fields