Note that there are some explanatory texts on larger screens.

plurals
  1. POHow would you compare two XML Documents?
    text
    copied!<p>As part of the base class for some extensive unit testing, I am writing a helper function which recursively compares the nodes of one XmlDocument object to another in C# (.NET). Some requirements of this:</p> <ul> <li>The first document is the <strong>source</strong>, e.g. what I want the XML document to look like. Thus the second is the one I want to find differences in and it must not contain <em>extra</em> nodes not in the first document.</li> <li>Must throw an exception when too many significant differences are found, and it should be easily understood by a human glancing at the description.</li> <li>Child element order is important, attributes can be in any order.</li> <li>Some attributes are ignorable; specifically <code>xsi:schemaLocation</code> and <code>xmlns:xsi</code>, though I would like to be able to pass in which ones are.</li> <li>Prefixes for namespaces must match in both attributes and elements.</li> <li>Whitespace between elements is irrelevant.</li> <li>Elements will <em>either</em> have child elements <em>or</em> <code>InnerText</code>, but not both.</li> </ul> <p>While I'm scrapping something together: <strong>has anyone written such code and would it be possible to share it here?</strong></p> <p>On an aside, what would you call the first and second documents? I've been referring to them as "source" and "target", but it feels wrong since the <strong>source</strong> is what I want the <strong>target</strong> to look like, else I throw an exception.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload