Querying XML using node numbers

Posted by CP on Stack Overflow See other posts from Stack Overflow or by CP
Published on 2010-05-27T14:49:32Z Indexed on 2010/05/27 14:51 UTC
Read the original article Hit count: 180

Filed under:
|

Okay, so I'm writing a utility that compares 2 XML documents using Microsoft's XML diff patch tool.

The result looks something like this:

<?xml version="1.0" encoding="utf-16"?><xd:xmldiff version="1.0" srcDocHash="10728157883908851288" options="IgnoreChildOrder IgnoreComments IgnoreWhitespace " fragments="yes" xmlns:xd="http://schemas.microsoft.com/xmltools/2002/xmldiff"><xd:node match="1"><xd:node match="1"><xd:node match="1"><xd:node match="2"><xd:node match="1"><xd:node match="1"><xd:node match="2"><xd:change match="1">testi22n2123</xd:change></xd:node></xd:node><xd:add match="/1/1/1/2/1/8" opid="1" /><xd:node match="7"><xd:node match="1"><xd:change match="1">31</xd:change></xd:node><xd:node match="2"><xd:change match="1">test2ing</xd:change></xd:node></xd:node><xd:remove match="8" opid="1" /></xd:node></xd:node></xd:node></xd:node></xd:node><xd:descriptor opid="1" type="move" /></xd:xmldiff>

What I'm trying to do is go back into the source document and get the source data that represents the difference. I initially tried creating an Xpath query, but as I understand it now this XmlDiff thing works off the DOM... which seems like the dinosaur of XML objects these days.

What's the best way to get at the node in the source XML by using the numbers provided in the diff result?

© Stack Overflow or respective owner

Related posts about c#

Related posts about Xml