XPath formula function
Easily extract values from XML messages using the Nodinite XPath
Formula plugin. This page shows you how to use XPath 1.0 expressions to retrieve data from message content, context values, or results from other formulas for your integrations.
✅ Extract single or multiple values from XML with a single formula
✅ Use standard XPath 1.0 expressions for flexible data selection
✅ See clear, real-world examples with input, formula, and result
Info
Support for XPath 1.0. For XPath 2.0, please review the XPath2 user-guide.
What does the XPath Formula do?
The XPath('Expression', Content)
Formula function extracts values from XML structures using standard XPath 1.0 syntax. You can use this function on message bodies, context values, or results from other formulas.
Example 1: Extracting a Value from XML Body
Input from Body
<Id>3</Id>
Formula Expression
XPath('/Id', body)
Result
3
Example 2: Extracting Multiple Values from Base64-encoded XML
Suppose your message body contains base64-encoded XML.
Input
PE9yZGVycz48SWQ+MzwvSWQ+PElkPjY8L0lkPjwvT3JkZXJzPg==
Formula Expression
XPath('/Orders/Id', base64decode(body))
Result
3
6
Example: Extracting multiple values from base64-encoded XML using XPath
Example 3: Extracting a Value from Message Context
Suppose you have a message context value with the key id
containing XML content.
Input
<Id>3</Id>
Formula Expression
XPath('/Id', context('id'))
Result
3
Example: Extracting a value from message context using XPath
Example 4: Using contains() in XPath
Suppose you want to extract a value from an attribute in an XML structure using the contains
XPath method and then cleanse the result.
Input
<Root>
<Data Data="SENDERID:13"/>
<Data Data="VATNO:SE19840410-1337"/>
<Data Data="RECEIVERID:37"/>
</Root>
Formula Expression
replace('VATNO:', '', XPath('/Root/Data[contains(@Data, ''VATNO'')]/@Data', body))
Result
SE19840410-1337
Features
- Extract single or multiple unique values from any XML content using XPath 1.0
- Use standard XPath expressions as defined by W3C
- Works with message body, context, or results from other Formula functions
- Ensures data integrity across integrated systems
Important
The XPath plugin loads the entire message into RAM. Only use this function on small messages to avoid performance issues.
How to use the XPath Formula
- Select Formula as the expression type plugin.
- Enter your XPath expression in the 'Expression' text area.
- Provide an XML string as the Content parameter (e.g., message body, Context, or another formula result).
Syntax
- Extract from message body:
XPath('Expression', body)
- Extract from message context:
XPath('Expression', context('MessageContextKey'))
- Extract from another formula:
XPath('Expression', SomeOtherFormulaFunction(Content))
Next Step
How to Add or manage Search Fields
How to Add or manage Log Views
Related Topics
- Expression Type Plugins are used in Search Fields
- What are Search Fields?
- What are Search Field Expressions?
- What are Message Types?
- What are Log Views?