---
title: Allowed XPath Expressions for Nodinite Search Fields
description: "Which XPath expressions work in the Nodinite XPath Search Field Expression plugins: the forward-only subset, how namespace prefixes are handled, what fails, and when to switch to the Formula xPath2 function."
---

# Allowed XPath expressions for Search Field Expressions

The four XPath plugins for [Search Field Expressions][] read XML with a forward-only stream reader, so they accept only XPath 1.0 expressions that move forward through the document. This page lists what works, how namespaces are handled, and what to do when your expression isn't supported. It applies to [XPath][], [XPath with RegEx][], [XPath on Wrapped XPath][], and [XPath on Message Context][].

## :fa-gears: Why only forward-only XPath works

The [Logging Service][] evaluates the expressions on every logged message. XML messages can be very large, so the XPath plugins use a read-only, forward-only stream reader based on Microsoft's XPathReader instead of loading the whole document. The reader can only move forward through the stream, which keeps memory use low but limits the XPath syntax:

* ✅ Supported: child steps, attributes, `node()`, `text()`, and predicates on attributes of the current element.
* ❌ Not supported: anything that needs to look back, such as the parent axis (`parent::node()`, `..`), `ancestor::`, or `preceding-sibling::`.

## :fa-table: Allowed XPath expressions: examples

All expressions below work with the forward-only reader.

|Expression|Message|Output|
|---|---|---|
|`/e`|`<e>1</e>`|1|
|`child::node()`|`<e>1</e>`|1|
|`e/child::node()`|`<e>1</e>`|1|
|`e/a/child::text()`|`<e><a>1</a><b>2</b></e>`|1|
|`e/a[@name='A']/child::text()`|`<e><a name="A">1</a><a name="B">2</a></e>`|1|
|`e/a/@name`|`<e><a name="A">1</a><a name="B">2</a></e>`|A<br/>B|
|`e/a/attribute::*`|`<e><a name="A">1</a><a name="B">2</a></e>`|A<br/>B|
|`Orders/Order/Id`|`<ns0:Orders xmlns:ns0="Common.Schemas/Nodinite/1.0"><Order><Id>101</Id></Order></ns0:Orders>`|101|

## :fa-sitemap: Namespaces

The XPath plugins match element names without namespace prefixes or declarations. Write the local element names only: `Orders/Order/Id` and `/Orders/Order/Id` match `<ns0:Orders xmlns:ns0="…">`, as the last row of the table shows, while `/ns0:Orders/Order/Id` returns nothing. Don't add prefixes such as `ns0:` to the expression. A default namespace (`xmlns="…"`) needs nothing either: `OrderEntry/OrderHeader/OrderId` matches as is. The same rule applies to the [Formula][] function [xPath][Formula xPath], but not to [xPath2][Formula xPath2], which needs the document's prefixes.

## :fa-wrench: When your expression isn't supported

>[!TIP]
>Always test your XPath expression in the Test Expression tab before you save the [Search Field][Search Fields] or start a re-index ([Test Your Expression][]).

>[!IMPORTANT]
>XPathReader is limited to what the underlying `XmlTextReader` can do, which is move forward through the stream. An expression that needs backward navigation, such as `..`, `parent::` or `ancestor::`, fails with *xpath is not supported!*. A predicate on a child element, such as `Orders/Order[Id=2]/City`, fails with *Can't get the child value*. In the Test Expression tab, both show as *Processed with warning*, with that text below.

![A look-back step refused by the forward-only reader and its forward rewrite, animated walkthrough (7.12)][1]  
*Animated walkthrough: on the logged Order Entry of order ORD-10005 in the [Order-to-Cash demo][], the [XPath][] expression `/OrderEntry/OrderHeader/OrderId/../../Customer/CustomerId` is refused with *xpath is not supported!*. Rewritten forward from the root, `/OrderEntry/Customer/CustomerId` returns `CUST-005`.*  

* Rewrite the expression to walk forward from the root: select the element you need directly instead of going to a child and back up to its parent.
* Use a predicate on an attribute of the element you select (`e/a[@name='A']`) instead of navigating back.
* For look-back steps or predicates on child elements, use the [Formula][] function [xPath2][Formula xPath2], which reads the whole document.

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

* :fa-flask: [Test Your Expression][]  
* :fa-plus: [Add or manage Search Field][]  
* :fa-function: [Formula xPath2][]  

## :fa-link-horizontal: Related Topics

* :fa-magnifying-glass: [XPath][]  
* :fa-magnifying-glass: [XPath with RegEx][]  
* :fa-magnifying-glass: [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][]  

[1]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/SearchField_XPathForwardOnly.gif

[Add or manage Search Field]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md
[Choose a plugin]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Overview.md#fa-signs-post-choose-a-plugin
[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
[Logging Service]:{ndr}/Core%20Services/Logging%20Service/Overview.md
[Order-to-Cash demo]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/Generate-O2C-Demo-Data.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]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/XPath.md
[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