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

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

## <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][] |
| 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][].

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

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

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

## <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][]  
* <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 Message Context][]  
* <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/XPath%20on%20Wrapped%20XPath/XPathOnWrappedXPath_Select_ExpressionType.png
[2]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/XPath%20on%20Wrapped%20XPath/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/Expression_XPathWrapped.gif

[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
[Formula]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/
[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]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/xpath/
[XPath on Message Context]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/xpath-on-message-context/
[XPath with RegEx]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/xpath-with-regex/