- 5 minutes to read

XPath on Wrapped XPath Search Field Expression Plugin

Easily extract unique values from embedded or wrapped XML content using the XPath on Wrapped XPath Search Field Expression Plugin. This page shows you how to configure, test, and use this plugin with clear input, configuration, and result examples.

✅ Extract single or multiple unique values from embedded XML in large messages ✅ Use two-stage XPath extraction for nested XML structures ✅ Works with XML encoded as text within XML elements ✅ Designed for high performance and self-service log views

🎯 Design Note: Perfect for extracting values from XML that's encoded as text inside another XML message!


What does the XPath on Wrapped XPath plugin do?

The XPath on Wrapped XPath plugin lets you extract one or more unique values from wrapped (encoded/nested) XML elements and attributes in the payload of Log Events. This is useful when XML content is embedded as text within another XML structure.

Key Features:

Info

Use Case: Extract data from XML that's been encoded as text and embedded in another XML message (common in envelope patterns or SOAP messages).

  • Extract values from XML embedded/encoded as text within XML
  • Use two XPath expressions: first to locate wrapped XML, second to extract values from it
  • Use XPath 1.0 expressions as defined by W3C
  • High-performance streaming reader supports large XML documents
  • Forward-only navigation for optimal performance

Tip

Use regular XPath for simple XML extraction. Use this plugin when XML is nested/wrapped as text within XML.


How it works

graph LR A[XML Message<br/>with Wrapped XML] --> B[1st XPath Expression<br/>Locate Wrapped XML] B --> C[Decode XML Text] C --> D[2nd XPath Expression<br/>Extract Values] D --> E[Search Field Result] style A fill:#e1f5ff style B fill:#fff4e1 style C fill:#ffe1f5 style D fill:#e1ffe1 style E fill:#f0e1ff

The process:

  1. Input: An XML message with XML content encoded as text within elements
  2. 1st XPath Expression: Locates the element(s) containing wrapped/encoded XML
  3. Decode: The wrapped XML text is decoded back to valid XML
  4. 2nd XPath Expression: Extracts the desired value(s) from the decoded XML
  5. Result: The extracted value(s) are stored as unique search field values

Each example below clearly separates the Input (XML message), the 1st XPath Expression (to select wrapped XML), the 2nd XPath Expression (to extract values from wrapped XML), and the Result (output value).


Example

Input:

<Orders>
<Order>&lt;Id&gt;101&lt;/Id&gt;</Order>
<Order>&lt;Id&gt;102&lt;/Id&gt;</Order>
</Orders>

1st XPath Expression:

Orders/Order

2nd XPath Expression:

Id

Result:

101
102

Additional examples

Example 1: Extract Order IDs from Embedded XML

Input:

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

1st XPath Expression:

Orders/Order

2nd XPath Expression:

Id

Result:

101
102

Test Expression Valid expression with state output, unique values, and total count.


How to use

  1. Select the 'XPath on Wrapped XPath' expression type plugin when configuring a Search Field
  2. Enter the 1st XPath expression to select the wrapped XML content
  3. Enter the 2nd XPath expression to extract the desired value(s) from the wrapped XML
  4. Finalize the configuration and select the Message Types to apply the expression
  5. Optionally, perform a re-index operation (Add or manage Search Field)

Extracted values are stored for as long as the Message Type retention is configured.


Test Expression

You can test your configuration in the 'Test Expression' tab when setting up a Search Field:

  1. Enter a sample payload in the 'Message Body' tab
  2. Select the 'XPath on Wrapped XPath' plugin SelectXPathOnWrappedXPathPlugin Here's an example selecting the 'XPath on Wrapped XPath' expression type plugin.
  3. Enter the 1st and 2nd XPath expressions
  4. Review the output and adjust as needed

If the expression is valid, you will see the unique values and total count:

Test Expression Valid expression with state output, unique values, and total count.

If the expression is invalid or does not match any data, you will see: No Result Example of an invalid expression yielding no result.


Important considerations

Performance:

  • This plugin uses a high-performance, read-only, fast-forward-only stream reader
  • Not all types of XPaths can be evaluated due to the forward-only nature
  • Designed for both small and large XML payloads

XML Encoding:

  • The outer XML structure must be valid XML
  • The wrapped/nested content must be properly XML-encoded (e.g., &lt; for <, &gt; for >)
  • Both XPath expressions must be valid XPath 1.0 syntax

Two-Stage Processing:

  • The 1st XPath locates elements containing encoded XML text
  • The 2nd XPath extracts values after decoding the XML
  • If either XPath fails, no values will be extracted


Next steps