3

I need to compare two XML chunks:

<elem type="p:type1" xmlns:p="myns" />

<elem type="g:type1" xmlns:g="myns" />

They are semantically equivalent once we see that the type attribute is QName and not just a string. Is there a tool that can do such a comparison once I provide the schema? Also, is there such an API?

Jakob
  • 3,570
  • 3
  • 36
  • 49
Yaron Naveh
  • 23,560
  • 32
  • 103
  • 158
  • Oops, now both duplicates have duplicate votes of each other! Please, nobody vote to close this one, do it on the other one. – Zifre Jun 06 '09 at 15:31
  • This one is a dupe of a lot of other questions, like http://stackoverflow.com/questions/547399/tool-or-library-for-comparing-xml-files and so should also be closed. –  Jun 06 '09 at 15:33
  • Okay, both of these should be closed. But the other one should just be deleted. This one should be left for others asking with different words. – Zifre Jun 06 '09 at 15:37
  • Someone please identify the dupes? This one: http://stackoverflow.com/questions/547399/tool-or-library-for-comparing-xml-files is focused on the tool. This one seems to be focued on programmatically doing the compare. – Cheeso Jun 06 '09 at 19:00

3 Answers3

1

You could download Xmldiffpatch.exe tool from the MSDN article "Using the XML Diff and Patch Tool in Your Applications"

Dmitry Pavlov
  • 30,789
  • 8
  • 97
  • 121
1

There are probably many tools that do this, one of them is Xml Diff and Path, via MS XML downloads

The Microsoft XML Diff and Patch utility can be used for comparing two XML documents and then patching the original document with the differences, to create a final document. The utility can detect structural changes (such as the move of an XML subtree) and can create an Xml Diff Language Diffgram (XDL diffgram or just diffgram) that describes the differences between the two XML documents. The diffgram can then be used to display these differences or perform a patch using the XML Patch tool.

XML Diff performs XML-based comparison of the XML documents, as opposed to a common lexical comparison. Therefore, it

Ignores the order attributes. Ignores insignificant white spaces. Does not differentiate between an empty element () and element with no content (). Does not care about the document encoding.

The tools are usable via cmd line and API.

Scott Weinstein
  • 18,890
  • 14
  • 78
  • 115
0

Meanwhile the diff/patch language XML Patch has been specified and deprecated Microsoft XML Diff. Have a look at this question for possible tools. In particular xmldiff seems to do proper comparison between XML documents.

Jakob
  • 3,570
  • 3
  • 36
  • 49