Skip to content
Documentation
Updated 3 minutes to read
Markdown

Allowed XPath expressions for Search Field Expressions

Section titled “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.

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

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
B
e/a/attribute::* <e><a name="A">1</a><a name="B">2</a></e> A
B
Orders/Order/Id <ns0:Orders xmlns:ns0="Common.Schemas/Nodinite/1.0"><Order><Id>101</Id></Order></ns0:Orders> 101

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, but not to xPath2, which needs the document's prefixes.

A look-back step refused by the forward-only reader and its forward rewrite, animated walkthrough (7.12)
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, which reads the whole document.

...

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