2 Replies Latest reply on Oct 28, 2009 1:23 PM by ACI_CF

    xmlsearch needs exact text to return anything


      How do you create a wildcard search using xmlsearch? Or a search that will return records matching some of the words entered in the query (in other words the query does not require the exact text to be entered to return the record.)? For example, if I want to search for "Network Support Technician" I cannot enter "Network Support" and get the results to come up, I'll have to enter "Network Support Technician" to get any results.  (code is below)


      <cfhttp url="http://www.server/webpage.cfm" method="GET">

      <CFSet xml=CFHTTP.FileContent>
      <CFSet xmlDoc = XMLParse(xml)>

      <cfset results = XMLSearch(xmlDoc, "//job[TITLE_STRING='#form.JobTitle#']")/>    

        • 1. Re: xmlsearch needs exact text to return anything
          Adam Cameron. Level 5

          xpath 1.0 supports a range of string functions.  It's perhaps an idea to have a read through this: http://www.w3.org/TR/xpath.  Or perhaps if you want something slightly less impenetrable: http://www.w3schools.com/XPath/xpath_functions.asp.




          1 person found this helpful
          • 2. Re: xmlsearch needs exact text to return anything
            ACI_CF Level 1

            I ended up going with another method over the xmlsearch for this. I've included the code below


            <CFSet xml=CFHTTP.FileContent>
            <CFSet xmlDoc = XMLParse(xml)>
            <cfset jobs = xmldoc.root.XmlChildren>
            <cfset size = ArrayLen(jobs)>


            <!--- create a query object with the job data --->
            <cfset myquery = QueryNew("JobID, Title") >
            <cfset temp = QueryAddRow(myquery, #size#)>
            <cfloop index="i" from = "1" to = #size#>
                <cfset temp = QuerySetCell(myquery, "JobID",
                    #xmldoc.root.job[i].jobpostingid_int.XmlText#, #i#)>
                <cfset temp = QuerySetCell(myquery, "Title",
                    #LCase(xmldoc.root.job[i].TITLE_STRING.XmlText)#, #i#)>



            <!--- Select entries with the Title name starting with N and dump the result --->
            <cfquery name="ImqTest" dbType="query">
               SELECT JobID, Title
               FROM myquery

            where Title LIKE '#LCase(form.JobTitle)#%'