Developing Apama Applications > Developing Adapters > Standard 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 normalised 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 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.