XML Node Value Comparisons and C#

Posted on 2011-05-10
Last Modified: 2013-11-11
What would be the best way to compare xml node values?

For instance in the same XML I was to check to see if the value of the node in this XPATH:


Is or is not equal to the:


Better to get the values of each XPath and compare or is there another way?
Question by:davism
    LVL 29

    Accepted Solution

    The question is not quite clear.

    If you need to compare two values, you get these values (using XPath to get nodes), compare these values - that's all. There is no any other way. There is no some xml or xpath specific tricks to do that.
    LVL 1

    Author Comment

    I understand that aspect. However, this was more question of other options. There is nothing I could do with XSLT or LINQ? If not, that's ok. I'm just wanting to see about exhausting the options.
    LVL 29

    Expert Comment

    Hmmm.. With LINQ you may find these two nodes but compare...

    Probably, you may take one node (value) as reference and search all node with the same value, e.g. Using LINQ. You may use this scenario, it depends on what you have and what you need.

    XSLT... I am not too big professional with XSLT - can't see any way to use it in your scenario.
    LVL 1

    Author Closing Comment

    Yep, I was using the SelectSingleNode aspect fro the XML to get the InnerText value of the node. Works fine. I posed this question because I just wasn't sure.

    Thanks for the confirmation on that. Very much appreciated.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    761 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

    12 Experts available now in Live!

    Get 1:1 Help Now