Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

case insensitive comparison between the value of a string variable and the value of a node in xml

hi,
I have an xml document as shown below.
I have a textbox in a windows form which takes a string value. I need to compare this value with the value of every name node in xml. I need to make this comparison as case insensitive.
For example if I enter "john" in the textbox then it needs to match up with the second <Person> name's node value.
I have my Xpath query working if I enter the same name as it is in the xml. (case senstive)
Can anybody please help me how to make it case insenstive?
Thank you.
<Persons>
  <Person>
    <name>Pat</name>
    <ssn>743242939</ssn>
  </Person>
  <Person>
    <name>John</name>
    <ssn>242290348</ssn>
  </Person>
</persons>

Open in new window

0
ipjyo
Asked:
ipjyo
  • 3
1 Solution
 
zadeveloperCommented:
Please can you attach your current search function, so that we know how you are expecting to view the results.
0
 
williamcampbellCommented:
Xpath has a function

 lower-case


/for
$doc in xcollection('/db/mydb/mycollection')//*
[
contains(lower-case(identity), lower-case('mYiD'))
]
order by $doc/identity ascending
return <doc id="{$doc/@id}">{$doc/identity}</doc>
}/

Open in new window

0
 
ipjyoAuthor Commented:
I have the following xpath query to select the record that consist of the name that is entered in text box.

foreach (XmlNode resultNode in XmlDoc.SelectNodes(string.Format("Persons/Person[@name = '{0}']", TextBox1.Text)))


Thanks.
0
 
ipjyoAuthor Commented:
I will try "lower-case" function and let you know.

Thanks.
0
 
ipjyoAuthor Commented:
Thank you.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now