---
title: XPath on Message Context Plugin – Extract XML Values from Context Properties
description: Extract unique values from XML stored in a context property with the Nodinite XPath on Message Context Search Field Expression plugin. Set the XPath and the case-sensitive Context key; see a tested order example.
---

# :fa-magnifying-glass: XPath on Message Context Search Field Expression Plugin

The **XPath on Message Context** plugin runs an [XPath][] 1.0 expression on XML stored in one context property of a [Log Event][], not on the message body. Use it when a system puts an XML document, such as an order summary, into a context property.

* ✅ Reads one named context property; the message body is ignored  
* ✅ Same XPath rules as the [XPath][] plugin, including element names without namespace prefixes  

![XPath on Message Context expression tested on the XMLContent context property, animated walkthrough (7.12)][4]  
*Animated walkthrough: pick the **XPath on Message Context** type, enter the order id path and the **Context key** `XMLContent`, add that key and its XML value on the **Message Context** tab of **Test Expression**, and test; 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][] |
| 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** (this page) |
| 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] |

When the context value isn't XML, use [Message Context Key][] for the whole value or [RegEx on Message Context][] for part of it; for the other plugins, see [Choose a plugin][].

## :fa-code: Expression syntax

<div class="mermaid">
graph LR
    A["fa:fa-key Context key<br/>names the property"] --> B["XML value of<br/>that property"]
    B --> C["XPath<br/>selects values"]
    C --> D["fa:fa-magnifying-glass-plus Unique values"]
    style A fill:#2678BD,color:#fff
    style B fill:#3F827B,color:#fff
    style C fill:#E47528,color:#fff
    style D fill:#93d16d,color:#000
</div>

*The Context key (blue) picks the property; its XML value (teal) is read with the XPath (orange); the matches become the [Search Field][Search Fields] values (green).*  

The plugin shows these fields:

| Field | What goes in it |
| --- | --- |
| **XPath** | The [XPath 1.0][XPath] expression to use on the context value, written from the root without a leading `/` (`Orders/Order/Id`). Element names match without namespace prefixes; the supported syntax is listed in [Allowed XPath expressions][]. |
| **Context key** | The name of the context property that holds the XML. The name is case sensitive. |

Duplicates are collapsed into unique values ([How expressions run][]). Pick the plugin in the **Type** list when you [add or manage a Search Field][Add or manage Search Field]. To test it, add the key and its XML value on the **Message Context** tab of the **Test Expression** tab ([Test Your Expression][]); the body may stay empty.

![Type list filtered on XPath on M, the XPath on Message Context plugin selected (7.12)][1]  
*Selecting **XPath on Message Context** in the **Type** list.*  

## :fa-list-ol: Examples

### Example 1: Get the order IDs from an XML context property

#### Input

| Context key | Value |
| --- | --- |
| `XMLContent` | `<ns0:Orders xmlns:ns0="Common.Schemas/Nodinite/1.0"><Order><Id>101</Id></Order><Order><Id>102</Id></Order></ns0:Orders>` |

#### Expression

| Field | Value |
| --- | --- |
| XPath | `Orders/Order/Id` |
| Context key | `XMLContent` |

#### Result

```text
101
102
```

![Test Expression tab with XPath on Message Context returning 101 and 102 from the XMLContent context key (7.12)][2]  
*XPath `Orders/Order/Id` on the `XMLContent` context key returns 2 unique matches; the Message Context tab holds the test value.*  

## :fa-triangle-exclamation: Limitations

* The Context key must match the property name exactly, including case. If the property is missing or its value isn't XML, the expression returns no value.
* Context properties and the reserved keys are described in [Context Options][]. Properties that the [ContextPropertiesFilters][] [System Parameter][System Parameters] removes aren't kept, so don't base a Search Field on them.
* The XPath uses the same forward-only reader as the [XPath][] plugin, so only the syntax in [Allowed XPath expressions][] works.

An expression 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][]  
* :fa-magnifying-glass: [XPath with RegEx][]  
* :fa-magnifying-glass: [XPath on wrapped XPath][XPath on Wrapped XPath]  
* :fa-key: [Message Context Key][]  
* :fa-key: [RegEx on Message Context][]  
* :fa-key: [RegEx on Message Context with capturing groups][]  
* :fa-function: [Formula xPath2][]  
* :fa-filter: [ContextPropertiesFilters][]  
* :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/XPath%20on%20Message%20Context/Select.png
[2]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath%20on%20Message%20Context/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/Expression_XPathMessageContext.gif

[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
[Context Options]:{ndr}/Core%20Services/Log%20Event/Features/Context%20Options.md
[ContextPropertiesFilters]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/ContextPropertiesFilters.md
[Formula]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.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 Event]:{ndr}/Core%20Services/Log%20Event/Overview.md
[Log Views]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/What%20is%20a%20Log%20View.md
[Message Context Key]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Message%20Context%20Key.md
[Message Types]:{ndr}/Repository%20Model/Message%20Types/Overview.md
[RegEx on Message Context]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/RegEx%20on%20Message%20Context.md
[RegEx on Message Context with capturing groups]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/RegEx%20on%20Message%20Context%20with%20capturing%20groups.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
[System Parameters]:{ndr}/Administration/5.%20Settings/5.%20System%20Parameters/Overview.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 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