<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>XMLSEARCH</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">XMLSEARCH</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
Uses an XPath language expression to search an XML document object.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Returns</span>
<p>
An array of XML object nodes that match the search criteria.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Category</span>
<p>
XML functions
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Function syntax</span><pre>XmlSearch(xmlDoc, xPathString)
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
cfxml, IsXML, XmlChildPos, XmlParse, XmlTransform; Chapter&#160;35, "Using XML and WDDX" in ColdFusion MX Developer's Guide
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">History</span>
<p>
ColdFusion&#160;MX&#160;7: Added support for attribute searches.
</p>

<p>
ColdFusion&#160;MX: Added this function.
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Parameters</span>
<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Usage</span>
<p>
The XmlSearch function does not support complete XPath syntax. It only supports XPath expressions that return one or more XML nodes and attribute searches. XPath expressions that return any other type of value, such as a string, number, or Boolean, generate errors.
</p>

<p>
XPath is specified by the World Wide Web Consortium (W3C). For detailed information on XPath, including XPath expression syntax, see the W3C website at www.w3.org/TR/xpath</a>. 
</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Example</span>
<p>
The following example extracts the elements named last, which contain employee last names, from an XML file, and displays the names.
</p>

<p>
The employeesimple.xml file contains the following XML:
</p>
<pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;employee&gt;
&lt;!-- A list of employees --&gt;
 &lt;name EmpType=&quot;Regular&quot;&gt;
  &lt;first&gt;Almanzo&lt;/first&gt;
  &lt;last&gt;Wilder&lt;/last&gt;
 &lt;/name&gt;
 &lt;name EmpType=&quot;Contract&quot;&gt;
  &lt;first&gt;Laura&lt;/first&gt;
  &lt;last&gt;Ingalls&lt;/last&gt;
 &lt;/name&gt;
&lt;/employee&gt;
</pre>
<p>
The CFML file contains the following lines:
</p>
<pre>&lt;cfscript&gt;
   myxmldoc = XmlParse(&quot;C:\CFusionMX7\wwwroot\examples\employeesimple.xml&quot;);
   selectedElements = XmlSearch(myxmldoc, &quot;/employee/name/last&quot;);
   for (i = 1; i LTE ArrayLen(selectedElements); i = i + 1)
      writeoutput(selectedElements[i].XmlText &amp; &quot;&lt;br&gt;&quot;);
&lt;/cfscript&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="XMLDOC">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">XMLDOC</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>XML document object</p>

  </td>
  </tr>
  </table>
</div>
<div id="XPATHSTRING">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">XPATHSTRING</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>


<p>XPath expression</p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
