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

Posted on 2010-01-04
Last Modified: 2013-11-11
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.

Open in new window

Question by:ipjyo
    LVL 13

    Expert Comment

    Please can you attach your current search function, so that we know how you are expecting to view the results.
    LVL 12

    Accepted Solution

    Xpath has a function


    $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


    Author Comment

    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)))


    Author Comment

    I will try "lower-case" function and let you know.


    Author Closing Comment

    Thank you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now