---
title: XPath Search Field Expression Plugin for XML in Nodinite
description: "Extract unique values from XML message bodies with the Nodinite XPath Search Field Expression plugin: XPath 1.0 on a forward-only stream reader, with examples for elements, attributes, namespaces, and several Message Types."
---

# :fa-magnifying-glass: XPath Search Field Expression Plugin

The **XPath** plugin extracts one or more unique [Search Field][Search Fields] 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)][1]  
*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.*  

## :fa-scale-balanced: When to use it

| 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][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][Formula xPath2] |

For the other plugins, see [Choose a plugin][].

## :fa-code: Expression syntax

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][Add or manage 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)][4]  
*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**.*  

## :fa-list-ol: Examples

### Example 1: Get the order IDs from an order message

#### Input

```xml
<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>
```

#### Expression

```text
Orders/Order/Id
```

#### Result

```text
101
102
```

![Test Expression tab with the XPath plugin returning 101 and 102 from an Orders message (7.12)][2]  
*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

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

#### Input

```xml
<ns0:Orders xmlns:ns0="Common.Schemas/Nodinite/1.0">
    <Order>
        <Id>101</Id>
        <Amount>1000</Amount>
    </Order>
</ns0:Orders>
```

```xml
<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>
```

#### Expression

```text
node()/Order/Id
```

#### Result

| 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)][ex2-orders] | ![XPath test with a node step as the root on an OrderResponse message, returning 101 and 102 (7.12)][ex2-response] |
| *The root is `ns0:Orders`; `node()` matches it.* | *The root is `ns0:OrderResponse`; the same expression matches it.* |

### Example 3: Read an attribute

#### Input

```xml
<Shipment>
    <Package trackingNo="1Z999AA10123456784" weight="2.4"/>
    <Package trackingNo="1Z999AA10123456791" weight="0.8"/>
</Shipment>
```

#### Expression

```text
Shipment/Package/@trackingNo
```

#### Result

```text
1Z999AA10123456784
1Z999AA10123456791
```

![XPath test reading the trackingNo attribute of each Package, returning two tracking numbers (7.12)][ex3]  
*`@trackingNo` selects the attribute on each `Package` element.*  

## :fa-triangle-exclamation: Limitations

* 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][Formula xPath2], which reads the whole document; the Formula function [xPath][Formula 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)][3]  
*No match: the test reports **Processed with warning: The Expression yields no result** instead of values.*  

## :fa-hand-point-right: Next Steps

* :fa-plus: [Add or manage Search Field][]  
* :fa-flask: [Test Your Expression][]  
* :fa-list-check: [Allowed XPath expressions][]  
* :fa-table-list: [Add or manage Log View][]  

## :fa-link-horizontal: Related Topics

* :fa-magnifying-glass: [XPath with RegEx][]  
* :fa-magnifying-glass: [XPath on wrapped XPath][XPath on Wrapped XPath]  
* :fa-magnifying-glass: [XPath on Message Context][]  
* :fa-function: [Formula xPath][]  
* :fa-function: [Formula xPath2][]  
* :fa-signs-post: [Choose a plugin][]  
* :fa-magnifying-glass-plus: [Search Field Expressions][]  
* :fa-magnifying-glass-plus: [Search Fields][]  
* :fa-file: [Message Types][]  
* :fa-table-list: [Log Views][]  

[1]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Expression_XPath.gif
[2]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath/Example1.png
[3]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/NoResult.png
[4]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath/XPathExpressionTypePluginSelection.png

[Add or manage Log View]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/Add%20or%20Manage%20Log%20View.md
[Add or manage Search Field]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md
[Allowed XPath expressions]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Troubleshooting/Allowed%20XPath%20expressions.md
[Choose a plugin]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Overview.md#fa-signs-post-choose-a-plugin
[ex2-orders]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath/Example2_Orders.png
[ex2-response]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath/Example2_OrderResponse.png
[ex3]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath/Example3.png
[Formula]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md
[Formula xPath]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/xPath.md
[Formula xPath2]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/xPath2.md
[How expressions run]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Overview.md#fa-gears-how-expressions-run
[Log Views]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/What%20is%20a%20Log%20View.md
[Message Types]:{ndr}/Repository%20Model/Message%20Types/Overview.md
[Search Field Expressions]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Overview.md
[Search Fields]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/What%20is%20a%20Search%20Field.md
[Test Your Expression]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md#test-your-expression
[XPath on Message Context]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/XPath%20on%20Message%20Context.md
[XPath on Wrapped XPath]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Xpath%20on%20wrapped%20XPath.md
[XPath with RegEx]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/XPath%20with%20RegEx.md