---
title: XPath on Wrapped XPath Plugin – Extract Values from XML Wrapped in XML
description: "Extract unique values from XML stored as escaped text inside another XML message with the Nodinite XPath on Wrapped XPath Search Field Expression plugin: one XPath finds the wrapped XML, a second reads values from it."
---

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

The **XPath on wrapped XPath** plugin extracts values from XML that is stored as escaped text (`&lt;Id&gt;101&lt;/Id&gt;`) inside an element of another XML message. A first [XPath][] finds the element that holds the wrapped XML in the message body; a second XPath reads values from the inner XML.

* ✅ Reads XML that an envelope or wrapper message carries as text  
* ✅ Both XPaths follow the [XPath][] plugin's rules, including element names without namespace prefixes  

![XPath on wrapped XPath expression tested on a logged message with escaped orders, animated walkthrough (7.12)][4]  
*Animated walkthrough: pick the **XPath on wrapped XPath** type, select the wrapping element with **XPath** and the order id with **XPath on wrapped XML**, 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][] |
| 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** (this page) |
| 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

<div class="mermaid">
graph LR
    A["fa:fa-file-code XML message body"] --> B["XPath<br/>finds the wrapping element"]
    B --> C["Inner XML<br/>(the element's text)"]
    C --> D["XPath on wrapped XML<br/>selects values"]
    D --> E["fa:fa-magnifying-glass-plus Unique values"]
    style A fill:#2678BD,color:#fff
    style B fill:#E47528,color:#fff
    style C fill:#3F827B,color:#fff
    style D fill:#9E59BB,color:#fff
    style E fill:#93d16d,color:#000
</div>

*The first XPath (orange) runs on the body (blue) and returns the wrapped XML (teal); the second XPath (purple) runs on that inner XML; the matches become the [Search Field][Search Fields] values (green).*  

The plugin shows these fields:

| Field | What goes in it |
| --- | --- |
| **XPath** | An [XPath][] 1.0 expression on the message body that selects the element(s) holding the wrapped XML (`Orders/Order`). |
| **XPath on wrapped XML** | An XPath 1.0 expression on the inner XML that selects the values to return (`Id`). |

Write both expressions from their root without a leading `/`. Element names match without namespace prefixes or declarations, in the outer and the inner XML alike; the supported syntax is listed in [Allowed XPath expressions][]. When the first XPath selects several elements, the second XPath runs on each of them.

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], and check the result in the **Test Expression** tab ([Test Your Expression][]).

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

## :fa-list-ol: Examples

### Example 1: Get the order IDs wrapped inside an Orders message

#### Input

```xml
<ns0:Orders xmlns:ns0="Common.Schemas/Nodinite/1.0">
    <Order>&lt;Id&gt;101&lt;/Id&gt;</Order>
    <Order>&lt;Id&gt;102&lt;/Id&gt;</Order>
</ns0:Orders>
```

#### Expression

| Field | Value |
| --- | --- |
| XPath | `Orders/Order` |
| XPath on wrapped XML | `Id` |

#### Result

```text
101
102
```

`Orders/Order` returns the text `<Id>101</Id>` and `<Id>102</Id>`; `Id` reads the value of each. The outer expression has no `ns0:` prefix and still matches the namespaced root.

![Test Expression tab with XPath on wrapped XPath returning 101 and 102 (7.12)][2]  
*XPath `Orders/Order` and XPath on wrapped XML `Id` return 2 unique matches from the escaped order IDs.*  

## :fa-triangle-exclamation: Limitations

* The outer message must be valid XML, and the wrapped content must be escaped XML (`&lt;` and `&gt;`) so that it is the element's text.
* Both XPaths use the same forward-only reader as the [XPath][] plugin, so only the syntax in [Allowed XPath expressions][] works.
* If either XPath matches nothing, no value is returned.

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 Message Context][]  
* :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/XPath%20on%20Wrapped%20XPath/XPathOnWrappedXPath_Select_ExpressionType.png
[2]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath%20on%20Wrapped%20XPath/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_XPathWrapped.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
[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 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]:{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 with RegEx]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/XPath%20with%20RegEx.md