Reputation: 159
I compare two Xml Files using the XMLDiff Api from Microsoft.
Now I want to interpret the output-file of the comparison and summarize it in some easy output
XML Output:
<?xml version="1.0" encoding="utf-8"?>
<xd:xmldiff version="1.0" srcDocHash="2653891925157739686" options="IgnoreChildOrder IgnoreNamespaces IgnorePrefixes " fragments="no" xmlns:xd="http://schemas.microsoft.com/xmltools/2002/xmldiff">
<xd:node match="2">
<xd:node match="6">
<xd:node match="1">
<xd:node match="2">
<xd:node match="1">
<xd:change match="@timestamp">8/27/2019 9:40:57 AM</xd:change>
</xd:node>
</xd:node>
<xd:node match="1">
<xd:node match="1">
<xd:change match="@timestamp">8/27/2019 9:40:57 AM</xd:change>
</xd:node>
</xd:node>
<xd:node match="3">
<xd:node match="1">
<xd:change match="@timestamp">8/27/2019 9:40:57 AM</xd:change>
</xd:node>
</xd:node>
<xd:node match="4">
<xd:node match="1">
<xd:change match="@timestamp">8/27/2019 9:40:57 AM</xd:change>
</xd:node>
</xd:node>
</xd:node>
</xd:node>
<xd:node match="1">
<xd:node match="4">
<xd:node match="1">
<xd:node match="1">
<xd:change match="@pageNr">fb5675f0-5178-4187-b878-6135a7e587ad</xd:change>
</xd:node>
</xd:node>
</xd:node>
</xd:node>
<xd:node match="4">
Now I want to get all the changes in the XML and list them in a Collection:
I tried it with using XDocument and iterating through the nodes but I dont really understand the match-attribute in here.
XDocument xmlDifffDoc = XDocument.Load(reader);
var allNodes = xmlDifffDoc.Descendants();
foreach (XElement e in allNodes)
{
if (e.Name.LocalName == "change")
{ ...
I cannot use XMLDiffView cause the code runs in a UnitTest...
How can I generate a list that contains all the nodes that changed and the changes?
Upvotes: 1
Views: 781
Reputation: 368
The documentation for the xmldiff output and specifically its Match attribute are here: https://documentation.help/Microsoft-XML-Diff/xmldiff_conceptual_029f.htm
Note: I really don't like including links, but the question is vague enough that in this case it is the best way to answer, and may save someone the trouble of locating these docs.
Upvotes: 0