• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 716
  • Last Modified:

XML Node Value Comparisons and C#

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:

MyXML/Parent/Mother/Address/State

Is or is not equal to the:

MyXML/Child/Son/Address/State

Better to get the values of each XPath and compare or is there another way?
0
davism
Asked:
davism
  • 2
  • 2
1 Solution
 
anarki_jimbelCommented:
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.
0
 
davismAuthor Commented:
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.
0
 
anarki_jimbelCommented:
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.
0
 
davismAuthor Commented:
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.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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