Skip to content
Documentation
Updated 4 minutes to read
Markdown

The XPath plugin extracts one or more unique Search Field values from XML in the message body with an XPath 1.0 expression. It reads the message with a forward-only stream reader, so it handles large XML payloads, but it accepts only the forward-only XPath subset listed in Allowed XPath expressions.

  • ✅ One expression returns every matching element or attribute value
  • ✅ Element names match without namespace prefixes, so Orders/Order/Id works on <ns0:Orders>
  • ✅ node() as the first step covers several Message Types with different root elements

XPath expression tested on a logged Orders message, animated walkthrough (7.12)
Animated walkthrough: in Edit Search Field Expressions, pick the XPath type, enter the order id path, apply it to the Orders Message Type, and test it on the logged message; the Result shows two unique matches, 101 and 102.

Your data Use
Plain XML in the message body; you want element or attribute values as they are XPath (this page)
Only part of an XML value (a file name in a path, an ID in a formatted string), or tag names inside an XML sub-tree XPath with RegEx
XML stored as escaped text inside an element of another XML message XPath on wrapped XPath
XML stored in a context property instead of the body XPath on Message Context
Full XPath over the whole document (look-back steps, predicates on child elements), or XPath combined with other functions (decode Base64 first, concatenate, compare) Formula with xPath2

For the other plugins, see Choose a plugin.

The XPath plugin has one field, Expression: the XPath 1.0 expression to evaluate against the message body.

  • Write the path from the root element without a leading / (Orders/Order/Id), as in the examples below.
  • Element names match without namespace prefixes or declarations: Orders/Order/Id matches <ns0:Orders xmlns:ns0="…">. Don't add prefixes to the expression.
  • Use @name or attribute::name for attribute values.
  • Use node() for a step whose element name varies, such as the root element of different Message Types.
  • Only forward navigation works. Axes such as parent:: or preceding-sibling:: can't be evaluated; see Allowed XPath expressions for the supported syntax.

Duplicates are collapsed into unique values; How expressions run explains how several values are stored. Pick the plugin in the Type list when you add or manage a Search Field, and check the result in the Test Expression tab (Test Your Expression).

Type list filtered on xpath, five plugins listed with XPath selected (7.12)
Filtering the Type list on "xpath" shows the five plugins with XPath in their name, JSON Path Base64 Decode with XPath included; this page covers XPath.

Example 1: Get the order IDs from an order message

Section titled “Example 1: Get the order IDs from an order message”
<ns0:Orders xmlns:ns0="Common.Schemas/Nodinite/1.0">
<Order>
<Id>101</Id>
<Amount>1000</Amount>
<City>Gothenburg</City>
</Order>
<Order>
<Id>102</Id>
<Amount>10</Amount>
<City>Stockholm</City>
</Order>
</ns0:Orders>
Orders/Order/Id
101
102

Test Expression tab with the XPath plugin returning 101 and 102 from an Orders message (7.12)
The expression has no ns0: prefix and still matches the namespaced Orders root; the test reports 2 unique matches.

Example 2: One expression for two Message Types

Section titled “Example 2: One expression for two Message Types”

Orders and order responses have different root elements. node() matches either root, so the same expression works on both Message Types.

<ns0:Orders xmlns:ns0="Common.Schemas/Nodinite/1.0">
<Order>
<Id>101</Id>
<Amount>1000</Amount>
</Order>
</ns0:Orders>
<ns0:OrderResponse xmlns:ns0="Common.Schemas/Nodinite/1.0">
<Order>
<Id>101</Id>
<Status>OK</Status>
</Order>
<Order>
<Id>102</Id>
<Status>Failed</Status>
</Order>
</ns0:OrderResponse>
node()/Order/Id
Orders Message Type OrderResponse Message Type
101 101, 102
XPath test with a node step as the root on an Orders message, returning 101 (7.12) XPath test with a node step as the root on an OrderResponse message, returning 101 and 102 (7.12)
The root is ns0:Orders; node() matches it. The root is ns0:OrderResponse; the same expression matches it.
<Shipment>
<Package trackingNo="1Z999AA10123456784" weight="2.4"/>
<Package trackingNo="1Z999AA10123456791" weight="0.8"/>
</Shipment>
Shipment/Package/@trackingNo
1Z999AA10123456784
1Z999AA10123456791

XPath test reading the trackingNo attribute of each Package, returning two tracking numbers (7.12)
@trackingNo selects the attribute on each Package element.

  • The plugin uses a forward-only stream reader based on Microsoft's XPathReader, so only XPath 1.0 expressions that read forward are supported. Check Allowed XPath expressions before you build an expression.
  • For look-back steps or predicates on child elements, use the Formula function xPath2, which reads the whole document; the Formula function xPath uses the same forward-only reader as this plugin.

An unsupported expression, or one that matches nothing, gives this result in the test:

Test result: Processed with warning, The Expression yields no result (7.12)
No match: the test reports Processed with warning: The Expression yields no result instead of values.

...

Version:
Release date: N/A
Loading...

Explore Nodinite for 30 days – completely free

  • Find out why this is the leading O&M software
  • Prove your business case
  • Test the self-service for the business side

Loading...

See how Nodinite resolves your technical issues, in a LIVE Demo!

Once you submit this request:

  • We will give you a short call to understand the issues you want to tackle.
  • Understand solutions you have tried and why were you not happy with them.
  • Book a convenient slot for a LIVE demo!

Loading...