breezback
asked on
GetXPath from XmlNode
I'm scanning an xml and I would like to compare the nodes between 2 xmls.
Let's say 1=xmlInput and 2=xmlReference.
I'm scanning the xmlInput recursively and I would like to check with xPath if it exists in the xmlReference.
for example: xmlInput
<root>
<children>
<child id='A' value='10'>
<child id='B' value='XXX'>
</children>
</root>
and xmlReference:
<root>
<children>
<child id='A' value='0'>
</children>
</root>
It would mean that XmlNode (child[id=B]) is not found in reference and I would like to remove it from xmlInput so the final xmlInput. It will look like:
<root>
<children>
<child id='A' value='10'>
</children>
</root>
Currently what I'm looking for is a method to return XPath from XmlNode. Any ideas?
Let's say 1=xmlInput and 2=xmlReference.
I'm scanning the xmlInput recursively and I would like to check with xPath if it exists in the xmlReference.
for example: xmlInput
<root>
<children>
<child id='A' value='10'>
<child id='B' value='XXX'>
</children>
</root>
and xmlReference:
<root>
<children>
<child id='A' value='0'>
</children>
</root>
It would mean that XmlNode (child[id=B]) is not found in reference and I would like to remove it from xmlInput so the final xmlInput. It will look like:
<root>
<children>
<child id='A' value='10'>
</children>
</root>
Currently what I'm looking for is a method to return XPath from XmlNode. Any ideas?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
good solutions!
MSDN:
http://msdn.microsoft.com/en-us/library/bb425822.aspx
HookedOnLINQ also have some good LINQ examples:
http://www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx
When you have done your comparison you can write a new input or just store it directly to a database.
Cheers