<html>
  <head>
  <title>XmlSearch()</title>
  </head>
  <body>
  <h1>XmlSearch()</h1>
  <cfset xmlBeatles=XMLParse(ExpandPath("Beatles.xml"))>
  <cfoutput>
  <table border="1" cellpadding="2" cellspacing="0">
  <tr>
   <th>XPath</th>
   <th>Result</th>
  </tr>
  <cfset arrXPs = ArrayNew(1)>
  <cfset ArrayAppend(arrXPs,"/beatles")>
  <cfset ArrayAppend(arrXPs,"/beatles/beatle/@link")>
  <cfset ArrayAppend(arrXPs,"/beatles//firstname")>
  <cfset ArrayAppend(arrXPs,"/beatles//firstname/text()")>
    <cfloop index="i" from="1" to="#ArrayLen(arrXPs)#">
   <cfset xp = arrXPs[i]>
   <cfset arrResult = XmlSearch(xmlBeatles,xp)>
   <tr valign="top">
    <td>#xp#</td>
    <td>
     <ol>
     <cfloop index="i" from="1" to="#ArrayLen(arrResult)#">
      <li>
       #XmlGetNodeType(arrResult[i])#:
        <cftry>
        #arrResult[i].XmlText#
        <cfcatch type="any">#arrResult[i]#</cfcatch>
       </cftry>
      </li>
     </cfloop>
     </ol>
    </td>
   </tr>
  </cfloop>
  </table>
  </cfoutput>
  </body>  
</html>