Connecting Apama Applications to External Components > Using Standard Adapters > Using Adapter Plug-ins > The XML codec plug-in > XPath examples
XPath examples
Consider the following XML:
<root>
   text1
   <a att="100.1">A text 1</a>
   <a>A text 2</a>
   <b att="300.0">
      <a att="400.4"/>
   </b>
   This is an interesting text string
</root>
Suppose that the following properties are set in the XML codec section of the IAF configuration file:
<property name="XMLField" value="Test"/>
<property name="XPath:Test->MyXPathResult.last-a"        value="*/a[last()]"/>
<property name="XPath:Test->MyXPathResult.first-att"     value="//@att"/>
<property name="XPath:Test->MyXPathResult.first-a-text"  value="/root/a[1]/text()"/>
<property name="XPath:Test->MyXPathResult.att>200"       value="//@att>200"/>
<property name="XPath:Test->MyXPathResult.att-count"     value="count(//@att)"/>
<property name="XPath:Test->MyXPathResult.text-contains" 
            value="contains(/cdata-root/text()[last()], &quot;interesting&quot;)"/>
With these property values, the XML fragment maps to the following normalized event fields:
"MyXPathResult.last-a"             = "A text 2"
"MyXPathResult.first-att"          = "100.1"
"MyXPathResult.first-a-text"       = "A text 1"
"MyXPathResult.att>200"            = "true"
"MyXPathResult.att-count"          = "3"
"MyXPathResult.text-contains"      = "true"
Copyright © 2013-2015 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.