- 4 minutes to read

XPath on Message Context Search Field Expression Plugin

Easily extract unique values from XML content within context properties using the XPath on Message Context 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 XML content in context properties ✅ Use high-performance streaming XPath extraction for large messages ✅ Works with BizTalk context properties containing XML ✅ Designed for high performance and self-service log views

🎯 Design Note: Perfect for extracting values from XML stored in context properties or metadata fields!


What does the XPath on Message Context plugin do?

The XPath on Message Context plugin lets you extract one or more unique values from XML content (elements and attributes) stored in context properties (metadata) of Log Events. Unlike XPath which works on the message body, this plugin targets XML within context properties.

Key Features:

Info

Use Case: Extract values from XML stored in BizTalk context properties, HTTP headers containing XML, or custom metadata fields with XML content.

  • Extract XML content from named context properties using XPath
  • 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 XPath for the message body. Use this plugin when XML is stored in context properties/metadata.


How it works

graph LR A[Log Event<br/>with Context Properties] --> B[Select Context Property<br/>containing XML] B --> C[Apply XPath Expression<br/>to XML content] C --> D[Extract Value(s)] 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: A logged message with context properties containing XML content
  2. Context Property: Select a named context property that stores XML data
  3. XPath Expression: Apply an XPath query that selects one or more values from the XML
  4. Result: The extracted value(s) are stored as unique search field values

Each example below clearly separates the Input (XML content), the Context Property (property name), the XPath Expression (pattern), and the Result (output value).


Example

Input:

<ns0:Orders xmlns:ns0="Common.Schemas/Nodinite/1.0">
    <Order>
        <Id>101</Id>
        <Amount>1000</Amount>
        <City>Karlstad</City>
    </Order>
    <Order>
        <Id>102</Id>
        <Amount>10</Amount>
        <City>Stockholm</City>
    </Order>
</ns0:Orders>

Context Property:

XMLContent

XPath Expression:

Orders/Order/Id

Result:

101
102

Additional examples

Example 1: Extract Order IDs from XML Content in Context Property

Input:

<ns0:Orders xmlns:ns0="Common.Schemas/Nodinite/1.0">
    <Order>
        <Id>101</Id>
        <Amount>1000</Amount>
        <City>Karlstad</City>
    </Order>
    <Order>
        <Id>102</Id>
        <Amount>10</Amount>
        <City>Stockholm</City>
    </Order>
</ns0:Orders>

Context Property:

XMLContent

XPath Expression:

Orders/Order/Id

Result:

101
102

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


How to use

  1. Select the 'XPath on Message Context' expression type plugin when configuring a Search Field
  2. Enter the name of the context property to extract the XML content from
  3. Enter the XPath expression to extract the desired value(s)
  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 Message Context' plugin SelectXPathOnWrappedXPathPlugin Here's an example selecting the 'XPath on Message Context' expression type plugin.
  3. Enter the name of the context property and the XPath expression
  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

Context Property Requirements:

  • The context property must contain valid XML content
  • Property names are case-sensitive
  • If the property doesn't exist or doesn't contain XML, no values will be extracted


Next steps