Apama 10.15.5 | Connecting Apama Applications to External Components | Standard IAF Plug-ins | Codec IAF Plug-ins | The XML codec IAF 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"