• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Name

XmlSearch

Synopsis

                    XmlSearch(XmlDocObj, XPath_exp)

Searches the specified ColdFusion XML document object using an XPath expression. If a successful match is made, the function returns an array of XML document object nodes that match the search criteria. The following example reads in an XML news feed from macromedia.com, parses it into an XML document object, uses XPath to return only the XML nodes containing tutorials, and outputs the results to the browser:

<cfhttp URL="http://www.macromedia.com/devnet/resources/macromedia_resources.xml"
        method="Get">
   
<cfset DesDev = XmlParse(cfhttp.FileContent)>
<cfset SearchResults = XmlSearch(DesDev, "/macromedia_resources/resource[attribute::
type='Tutorial']")>
   
<h2>Available Tutorials</h2>
<cfloop index="i" from="1" to="#ArrayLen(SearchResults)#">
  <cfoutput>
  <a href="#SearchResults[i].URL.XmlText#">#SearchResults[i].Title.XmlText#</a><br>
  </cfoutput>
</cfloop>

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint