• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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