---
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."
---

# <i class="fal fa-magnifying-glass" aria-hidden="true"></i> 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.*  

## <i class="fal fa-scale-balanced" aria-hidden="true"></i> 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][].

## <i class="fal fa-code" aria-hidden="true"></i> 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**.*  

## <i class="fal fa-list-ol" aria-hidden="true"></i> 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.*  

## <i class="fal fa-triangle-exclamation" aria-hidden="true"></i> 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.*  

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

* <i class="fal fa-plus" aria-hidden="true"></i> [Add or manage Search Field][]  
* <i class="fal fa-flask" aria-hidden="true"></i> [Test Your Expression][]  
* <i class="fal fa-list-check" aria-hidden="true"></i> [Allowed XPath expressions][]  
* <i class="fal fa-table-list" aria-hidden="true"></i> [Add or manage Log View][]  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

* <i class="fal fa-magnifying-glass" aria-hidden="true"></i> [XPath with RegEx][]  
* <i class="fal fa-magnifying-glass" aria-hidden="true"></i> [XPath on wrapped XPath][XPath on Wrapped XPath]  
* <i class="fal fa-magnifying-glass" aria-hidden="true"></i> [XPath on Message Context][]  
* <i class="fal fa-function" aria-hidden="true"></i> [Formula xPath][]  
* <i class="fal fa-function" aria-hidden="true"></i> [Formula xPath2][]  
* <i class="fal fa-signs-post" aria-hidden="true"></i> [Choose a plugin][]  
* <i class="fal fa-magnifying-glass-plus" aria-hidden="true"></i> [Search Field Expressions][]  
* <i class="fal fa-magnifying-glass-plus" aria-hidden="true"></i> [Search Fields][]  
* <i class="fal fa-file" aria-hidden="true"></i> [Message Types][]  
* <i class="fal fa-table-list" aria-hidden="true"></i> [Log Views][]  

[1]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Expression_XPath.gif
[2]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath/Example1.png
[3]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/NoResult.png
[4]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath/XPathExpressionTypePluginSelection.png

[Add or manage Log View]:https://docs.nodinite.com/administration/log-management/log-views/features/add-or-manage-log-view/
[Add or manage Search Field]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/
[Allowed XPath expressions]:https://docs.nodinite.com/administration/log-management/search-fields/troubleshooting/allowed-xpath-expressions/
[Choose a plugin]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/#fa-signs-post-choose-a-plugin
[ex2-orders]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath/Example2_Orders.png
[ex2-response]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath/Example2_OrderResponse.png
[ex3]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath/Example3.png
[Formula]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/
[Formula xPath]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/xpath/
[Formula xPath2]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/xpath2/
[How expressions run]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/#fa-gears-how-expressions-run
[Log Views]:https://docs.nodinite.com/administration/log-management/log-views/features/what-is-a-log-view/
[Message Types]:https://docs.nodinite.com/repository-model/message-types/overview/
[Search Field Expressions]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/
[Search Fields]:https://docs.nodinite.com/administration/log-management/search-fields/features/what-is-a-search-field/
[Test Your Expression]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/#test-your-expression
[XPath on Message Context]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/xpath-on-message-context/
[XPath on Wrapped XPath]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/xpath-on-wrapped-xpath/
[XPath with RegEx]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/xpath-with-regex/