• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

XMLSearch case sensitivity

New Here ,
Oct 28, 2009 Oct 28, 2009

Copy link to clipboard

Copied

I'm trying to do a query using xmlsearch, but it is case sensitive as to the text being searched. If you do a search for "network" it does not return anything, however if you do a search on "Network" it returns the data. How can you get the search not to be case sensitive and to return the data regardless of the case?  (code is below)

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


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


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

TOPICS
Advanced techniques

Views

981

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 28, 2009 Oct 28, 2009

Copy link to clipboard

Copied

See my comment on Ben Nadel's blog: http://www.bennadel.com/blog/1491-Ask-Ben-Finding-XML-Nodes-That-Have-Children-With-The-Given-Case-Insensitive-Phrase.htm.

Quote:

There's another couple of options here Ben:

<cfset aNoCase1 = xmlSearch(xmlFeed, "//item[contains(translate(title/text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'coldfusion')]")>

It's a bit long-winded, but it works.

This next one conditionally works... it's OK for looking up the count of results, but as it transforms the XML, one has to be cautious with what one does with the results:

<cfset aNoCase2 = xmlSearch(lcase(xmlFeed), lcase("//item[contains(title/text(), 'COLDFusion')]"))>

Another note here is that the the nodes in the resultant array are not references to the original nodes, they're references to a separate XML doc which is created by the lcase(xmlFeed) operation. So one cannot update the nodes in the array and expect to see the updates in the original doc (like one usually would). So this one comes with some caveats, but if those are not a concern: it's an adequate approach.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 28, 2009 Oct 28, 2009

Copy link to clipboard

Copied

LATEST

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.jobpostingid_int.XmlText#, #i#)>
    <cfset temp = QuerySetCell(myquery, "Title",
        #LCase(xmldoc.root.job.TITLE_STRING.XmlText)#, #i#)>

</cfloop>

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

</cfquery>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation