How can I diff two XML files?
On Linux, how could I generate a diff between two XML files?
Ideally, I would like to be able configure it to some things strict, or loosen some things, like whitespace, or attribute order.
I'll often care that the files are functionally the same, but diff by itself, would be annoying to use, especially if the XML file doesn't have a lot of linebreaks.
For example, the following should really be okay to me:
<tag att1="one" att2="two">
content
</tag>
<tag att2="two" att1="one">
content
</tag>
linux xml diff
add a comment |
On Linux, how could I generate a diff between two XML files?
Ideally, I would like to be able configure it to some things strict, or loosen some things, like whitespace, or attribute order.
I'll often care that the files are functionally the same, but diff by itself, would be annoying to use, especially if the XML file doesn't have a lot of linebreaks.
For example, the following should really be okay to me:
<tag att1="one" att2="two">
content
</tag>
<tag att2="two" att1="one">
content
</tag>
linux xml diff
add a comment |
On Linux, how could I generate a diff between two XML files?
Ideally, I would like to be able configure it to some things strict, or loosen some things, like whitespace, or attribute order.
I'll often care that the files are functionally the same, but diff by itself, would be annoying to use, especially if the XML file doesn't have a lot of linebreaks.
For example, the following should really be okay to me:
<tag att1="one" att2="two">
content
</tag>
<tag att2="two" att1="one">
content
</tag>
linux xml diff
On Linux, how could I generate a diff between two XML files?
Ideally, I would like to be able configure it to some things strict, or loosen some things, like whitespace, or attribute order.
I'll often care that the files are functionally the same, but diff by itself, would be annoying to use, especially if the XML file doesn't have a lot of linebreaks.
For example, the following should really be okay to me:
<tag att1="one" att2="two">
content
</tag>
<tag att2="two" att1="one">
content
</tag>
linux xml diff
linux xml diff
edited Aug 8 '12 at 10:27
slhck
160k47445467
160k47445467
asked Dec 7 '09 at 16:27
qediqedi
7911710
7911710
add a comment |
add a comment |
8 Answers
8
active
oldest
votes
One approach would be to first turn both XML files into Canonical XML, and compare the results using diff. For example, xmllint can be used to canonicalize XML.
$ xmllint --c14n one.xml > 1.xml
$ xmllint --c14n two.xml > 2.xml
$ diff 1.xml 2.xml
Or as a one-liner.
$ diff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)
1
Never knew about the --c14n switch in xmllint. That's handy.
– qedi
Dec 10 '09 at 20:21
17
You can do it in one line toovimdiff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)
– Nathan Villaescusa
Mar 3 '13 at 1:53
and xmllint ships with OS X
– ClintM
Sep 20 '16 at 16:17
4
In case it wasn't obvious, c14n is an abbreviation for canonicalization.
– Brandin
Nov 8 '16 at 17:53
2
It is better to execute an additional step before diff - formatting of both XMLs (xmllint --format). Because I've noticed that without this step diff shows more differences than necessary.
– ka3ak
Dec 9 '16 at 12:07
add a comment |
Jukka's answer did not work for me, but it did point to Canonical XML. Neither --c14n nor --c14n11 sorted the attributes, but i did find the --exc-c14n switch did sort the attributes. --exc-c14n is not listed in the man page, but described on the command line as "W3C exclusive canonical format".
$ xmllint --exc-c14n one.xml > 1.xml
$ xmllint --exc-c14n two.xml > 2.xml
$ diff 1.xml 2.xml
$ xmllint | grep c14
--c14n : save in W3C canonical format v1.0 (with comments)
--c14n11 : save in W3C canonical format v1.1 (with comments)
--exc-c14n : save in W3C exclusive canonical format (with comments)
$ rpm -qf /usr/bin/xmllint
libxml2-2.7.6-14.el6.x86_64
libxml2-2.7.6-14.el6.i686
$ cat /etc/system-release
CentOS release 6.5 (Final)
Warning --exc-c14n strips out the xml header whereas the --c14n prepends the xml header if not there.
add a comment |
Tried to use @Jukka Matilainen's answer but had problems with white-space (one of the files was a huge one-liner).
Using --format helps to skip white-space differences.
xmllint --format one.xml > 1.xml
xmllint --format two.xml > 2.xml
diff 1.xml 2.xml
Note: Use vimdiff command for side-by-side comparison of the xmls.
In my casetwo.xmlwas generated fromone.xmlby a script. So I just needed to check what was added/removed by the script.
– GuruM
Aug 8 '12 at 10:36
This was the option I needed. Supposedly the most canonical version can be obtained by combining--formatwith--exc-c14n; will probably be still slower to process :(
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:05
It's been quite some time since I wrote the answer, but I faintly remember using the --exc-c14n flag. However, diff-ing the output with/without the flag showed no differences so just stopped using it. Dropping unnecessary/unused flags might make the process faster.
– GuruM
Dec 21 '14 at 6:49
5
The--exc-c14noption specifies sorting of the attributes. In your specific files the attributes probably were already sorted, but the general advice would be to use the combination--format --exc-c14n.
– ᴠɪɴᴄᴇɴᴛ
Dec 22 '14 at 14:33
add a comment |
Diffxml gets the basic functionality correct, though it doesn't seem to offer many options for configuration.
Edit: Project Diffxml has been migrated to GitHub since 2013.
It's not quite there yet, but it looks promising at least.
– qedi
Dec 7 '09 at 17:02
not useful for large files though, died after eating 40GB (RAM + SWAP) when comparing two files ~20k lines each
– meta
Oct 26 '17 at 6:27
note that project appears to be dead, with last update in 2013
– Mateusz Konieczny
Oct 9 '18 at 7:53
add a comment |
If you wish to also ignore the order of child elements, I wrote a simple python tool for this called xmldiffs:
Compare two XML files, ignoring element and attribute order.
Usage:
xmldiffs [OPTION] FILE1 FILE2
Any extra options are passed to the
diffcommand.
Get it at https://github.com/joh/xmldiffs
add a comment |
I use Beyond Compare to compare all types of text based files. They produce versions for Windows and Linux.
1
Plain text comparisons would say the two lines differed, whereas the OP wants them to be reported as the same.
– ChrisF
Dec 7 '09 at 16:33
4
i.e. Canonically compare the XML.
– Chris W. Rea
Dec 9 '09 at 20:08
1
Beyond Compare really sucks for this. It seems to just not be aware of XML elements and do mostly just text comparison.
– Rob K
May 23 '16 at 17:54
add a comment |
Our SD Smart Differencer compares documents based on structure as opposed to actual layout.
There's an XML Smart Differencer. For XML, that means matching order of tags and content. It should note that the text string in the specific fragment you indicated was different. It presently doesn't understand the XML notion of tag attributes indicating whether
whitespace is normalized vs. significant.
In your SO profile you provide full disclosure about your employer; I'd have preferred a short disclaimer inside your answer as well :) BTW, I tried to download an evaluation copy, but the request form is 'smart' (via JS) enough to disable the combination XML with Smart Differencer (also the latter in combination with Python, although possible according to the SD product page)?
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:03
1
Ah. Thanks for the reminder. This is an answer from a time before there was a clear SO policy on this. I'm revising the answer to signal the relationship in SO policy compliant answer.
– Ira Baxter
Nov 27 '14 at 15:52
I'll check the download page; not all of our live products make into that list. Yes, these exist.
– Ira Baxter
Nov 27 '14 at 15:53
I checked the download page. Yes, the XML smart differencer is not there. I'll have the back-room guys work on fixing that; should be there in 1-2 weeks at most (they have a backlog, don't we all?) In meantime, if you want to try it, send email (see bio).
– Ira Baxter
Jan 26 '15 at 20:16
1
Linked page has no word "XML" in it.
– Mateusz Konieczny
Oct 9 '18 at 7:52
|
show 1 more comment
Not sure whether (the dependence of) an online tool counts as a solution but, for what it's worth, I got good result in this online XML comparison tool. It simply works.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f79920%2fhow-can-i-diff-two-xml-files%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
One approach would be to first turn both XML files into Canonical XML, and compare the results using diff. For example, xmllint can be used to canonicalize XML.
$ xmllint --c14n one.xml > 1.xml
$ xmllint --c14n two.xml > 2.xml
$ diff 1.xml 2.xml
Or as a one-liner.
$ diff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)
1
Never knew about the --c14n switch in xmllint. That's handy.
– qedi
Dec 10 '09 at 20:21
17
You can do it in one line toovimdiff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)
– Nathan Villaescusa
Mar 3 '13 at 1:53
and xmllint ships with OS X
– ClintM
Sep 20 '16 at 16:17
4
In case it wasn't obvious, c14n is an abbreviation for canonicalization.
– Brandin
Nov 8 '16 at 17:53
2
It is better to execute an additional step before diff - formatting of both XMLs (xmllint --format). Because I've noticed that without this step diff shows more differences than necessary.
– ka3ak
Dec 9 '16 at 12:07
add a comment |
One approach would be to first turn both XML files into Canonical XML, and compare the results using diff. For example, xmllint can be used to canonicalize XML.
$ xmllint --c14n one.xml > 1.xml
$ xmllint --c14n two.xml > 2.xml
$ diff 1.xml 2.xml
Or as a one-liner.
$ diff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)
1
Never knew about the --c14n switch in xmllint. That's handy.
– qedi
Dec 10 '09 at 20:21
17
You can do it in one line toovimdiff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)
– Nathan Villaescusa
Mar 3 '13 at 1:53
and xmllint ships with OS X
– ClintM
Sep 20 '16 at 16:17
4
In case it wasn't obvious, c14n is an abbreviation for canonicalization.
– Brandin
Nov 8 '16 at 17:53
2
It is better to execute an additional step before diff - formatting of both XMLs (xmllint --format). Because I've noticed that without this step diff shows more differences than necessary.
– ka3ak
Dec 9 '16 at 12:07
add a comment |
One approach would be to first turn both XML files into Canonical XML, and compare the results using diff. For example, xmllint can be used to canonicalize XML.
$ xmllint --c14n one.xml > 1.xml
$ xmllint --c14n two.xml > 2.xml
$ diff 1.xml 2.xml
Or as a one-liner.
$ diff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)
One approach would be to first turn both XML files into Canonical XML, and compare the results using diff. For example, xmllint can be used to canonicalize XML.
$ xmllint --c14n one.xml > 1.xml
$ xmllint --c14n two.xml > 2.xml
$ diff 1.xml 2.xml
Or as a one-liner.
$ diff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)
edited Jun 22 '18 at 15:01
Stephen Rauch
2,27581725
2,27581725
answered Dec 9 '09 at 20:06
Jukka MatilainenJukka Matilainen
2,084137
2,084137
1
Never knew about the --c14n switch in xmllint. That's handy.
– qedi
Dec 10 '09 at 20:21
17
You can do it in one line toovimdiff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)
– Nathan Villaescusa
Mar 3 '13 at 1:53
and xmllint ships with OS X
– ClintM
Sep 20 '16 at 16:17
4
In case it wasn't obvious, c14n is an abbreviation for canonicalization.
– Brandin
Nov 8 '16 at 17:53
2
It is better to execute an additional step before diff - formatting of both XMLs (xmllint --format). Because I've noticed that without this step diff shows more differences than necessary.
– ka3ak
Dec 9 '16 at 12:07
add a comment |
1
Never knew about the --c14n switch in xmllint. That's handy.
– qedi
Dec 10 '09 at 20:21
17
You can do it in one line toovimdiff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)
– Nathan Villaescusa
Mar 3 '13 at 1:53
and xmllint ships with OS X
– ClintM
Sep 20 '16 at 16:17
4
In case it wasn't obvious, c14n is an abbreviation for canonicalization.
– Brandin
Nov 8 '16 at 17:53
2
It is better to execute an additional step before diff - formatting of both XMLs (xmllint --format). Because I've noticed that without this step diff shows more differences than necessary.
– ka3ak
Dec 9 '16 at 12:07
1
1
Never knew about the --c14n switch in xmllint. That's handy.
– qedi
Dec 10 '09 at 20:21
Never knew about the --c14n switch in xmllint. That's handy.
– qedi
Dec 10 '09 at 20:21
17
17
You can do it in one line too
vimdiff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)– Nathan Villaescusa
Mar 3 '13 at 1:53
You can do it in one line too
vimdiff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)– Nathan Villaescusa
Mar 3 '13 at 1:53
and xmllint ships with OS X
– ClintM
Sep 20 '16 at 16:17
and xmllint ships with OS X
– ClintM
Sep 20 '16 at 16:17
4
4
In case it wasn't obvious, c14n is an abbreviation for canonicalization.
– Brandin
Nov 8 '16 at 17:53
In case it wasn't obvious, c14n is an abbreviation for canonicalization.
– Brandin
Nov 8 '16 at 17:53
2
2
It is better to execute an additional step before diff - formatting of both XMLs (xmllint --format). Because I've noticed that without this step diff shows more differences than necessary.
– ka3ak
Dec 9 '16 at 12:07
It is better to execute an additional step before diff - formatting of both XMLs (xmllint --format). Because I've noticed that without this step diff shows more differences than necessary.
– ka3ak
Dec 9 '16 at 12:07
add a comment |
Jukka's answer did not work for me, but it did point to Canonical XML. Neither --c14n nor --c14n11 sorted the attributes, but i did find the --exc-c14n switch did sort the attributes. --exc-c14n is not listed in the man page, but described on the command line as "W3C exclusive canonical format".
$ xmllint --exc-c14n one.xml > 1.xml
$ xmllint --exc-c14n two.xml > 2.xml
$ diff 1.xml 2.xml
$ xmllint | grep c14
--c14n : save in W3C canonical format v1.0 (with comments)
--c14n11 : save in W3C canonical format v1.1 (with comments)
--exc-c14n : save in W3C exclusive canonical format (with comments)
$ rpm -qf /usr/bin/xmllint
libxml2-2.7.6-14.el6.x86_64
libxml2-2.7.6-14.el6.i686
$ cat /etc/system-release
CentOS release 6.5 (Final)
Warning --exc-c14n strips out the xml header whereas the --c14n prepends the xml header if not there.
add a comment |
Jukka's answer did not work for me, but it did point to Canonical XML. Neither --c14n nor --c14n11 sorted the attributes, but i did find the --exc-c14n switch did sort the attributes. --exc-c14n is not listed in the man page, but described on the command line as "W3C exclusive canonical format".
$ xmllint --exc-c14n one.xml > 1.xml
$ xmllint --exc-c14n two.xml > 2.xml
$ diff 1.xml 2.xml
$ xmllint | grep c14
--c14n : save in W3C canonical format v1.0 (with comments)
--c14n11 : save in W3C canonical format v1.1 (with comments)
--exc-c14n : save in W3C exclusive canonical format (with comments)
$ rpm -qf /usr/bin/xmllint
libxml2-2.7.6-14.el6.x86_64
libxml2-2.7.6-14.el6.i686
$ cat /etc/system-release
CentOS release 6.5 (Final)
Warning --exc-c14n strips out the xml header whereas the --c14n prepends the xml header if not there.
add a comment |
Jukka's answer did not work for me, but it did point to Canonical XML. Neither --c14n nor --c14n11 sorted the attributes, but i did find the --exc-c14n switch did sort the attributes. --exc-c14n is not listed in the man page, but described on the command line as "W3C exclusive canonical format".
$ xmllint --exc-c14n one.xml > 1.xml
$ xmllint --exc-c14n two.xml > 2.xml
$ diff 1.xml 2.xml
$ xmllint | grep c14
--c14n : save in W3C canonical format v1.0 (with comments)
--c14n11 : save in W3C canonical format v1.1 (with comments)
--exc-c14n : save in W3C exclusive canonical format (with comments)
$ rpm -qf /usr/bin/xmllint
libxml2-2.7.6-14.el6.x86_64
libxml2-2.7.6-14.el6.i686
$ cat /etc/system-release
CentOS release 6.5 (Final)
Warning --exc-c14n strips out the xml header whereas the --c14n prepends the xml header if not there.
Jukka's answer did not work for me, but it did point to Canonical XML. Neither --c14n nor --c14n11 sorted the attributes, but i did find the --exc-c14n switch did sort the attributes. --exc-c14n is not listed in the man page, but described on the command line as "W3C exclusive canonical format".
$ xmllint --exc-c14n one.xml > 1.xml
$ xmllint --exc-c14n two.xml > 2.xml
$ diff 1.xml 2.xml
$ xmllint | grep c14
--c14n : save in W3C canonical format v1.0 (with comments)
--c14n11 : save in W3C canonical format v1.1 (with comments)
--exc-c14n : save in W3C exclusive canonical format (with comments)
$ rpm -qf /usr/bin/xmllint
libxml2-2.7.6-14.el6.x86_64
libxml2-2.7.6-14.el6.i686
$ cat /etc/system-release
CentOS release 6.5 (Final)
Warning --exc-c14n strips out the xml header whereas the --c14n prepends the xml header if not there.
answered Mar 4 '14 at 12:51
rjtrjt
64921016
64921016
add a comment |
add a comment |
Tried to use @Jukka Matilainen's answer but had problems with white-space (one of the files was a huge one-liner).
Using --format helps to skip white-space differences.
xmllint --format one.xml > 1.xml
xmllint --format two.xml > 2.xml
diff 1.xml 2.xml
Note: Use vimdiff command for side-by-side comparison of the xmls.
In my casetwo.xmlwas generated fromone.xmlby a script. So I just needed to check what was added/removed by the script.
– GuruM
Aug 8 '12 at 10:36
This was the option I needed. Supposedly the most canonical version can be obtained by combining--formatwith--exc-c14n; will probably be still slower to process :(
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:05
It's been quite some time since I wrote the answer, but I faintly remember using the --exc-c14n flag. However, diff-ing the output with/without the flag showed no differences so just stopped using it. Dropping unnecessary/unused flags might make the process faster.
– GuruM
Dec 21 '14 at 6:49
5
The--exc-c14noption specifies sorting of the attributes. In your specific files the attributes probably were already sorted, but the general advice would be to use the combination--format --exc-c14n.
– ᴠɪɴᴄᴇɴᴛ
Dec 22 '14 at 14:33
add a comment |
Tried to use @Jukka Matilainen's answer but had problems with white-space (one of the files was a huge one-liner).
Using --format helps to skip white-space differences.
xmllint --format one.xml > 1.xml
xmllint --format two.xml > 2.xml
diff 1.xml 2.xml
Note: Use vimdiff command for side-by-side comparison of the xmls.
In my casetwo.xmlwas generated fromone.xmlby a script. So I just needed to check what was added/removed by the script.
– GuruM
Aug 8 '12 at 10:36
This was the option I needed. Supposedly the most canonical version can be obtained by combining--formatwith--exc-c14n; will probably be still slower to process :(
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:05
It's been quite some time since I wrote the answer, but I faintly remember using the --exc-c14n flag. However, diff-ing the output with/without the flag showed no differences so just stopped using it. Dropping unnecessary/unused flags might make the process faster.
– GuruM
Dec 21 '14 at 6:49
5
The--exc-c14noption specifies sorting of the attributes. In your specific files the attributes probably were already sorted, but the general advice would be to use the combination--format --exc-c14n.
– ᴠɪɴᴄᴇɴᴛ
Dec 22 '14 at 14:33
add a comment |
Tried to use @Jukka Matilainen's answer but had problems with white-space (one of the files was a huge one-liner).
Using --format helps to skip white-space differences.
xmllint --format one.xml > 1.xml
xmllint --format two.xml > 2.xml
diff 1.xml 2.xml
Note: Use vimdiff command for side-by-side comparison of the xmls.
Tried to use @Jukka Matilainen's answer but had problems with white-space (one of the files was a huge one-liner).
Using --format helps to skip white-space differences.
xmllint --format one.xml > 1.xml
xmllint --format two.xml > 2.xml
diff 1.xml 2.xml
Note: Use vimdiff command for side-by-side comparison of the xmls.
edited Aug 8 '12 at 10:33
answered Aug 8 '12 at 9:58
GuruMGuruM
24126
24126
In my casetwo.xmlwas generated fromone.xmlby a script. So I just needed to check what was added/removed by the script.
– GuruM
Aug 8 '12 at 10:36
This was the option I needed. Supposedly the most canonical version can be obtained by combining--formatwith--exc-c14n; will probably be still slower to process :(
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:05
It's been quite some time since I wrote the answer, but I faintly remember using the --exc-c14n flag. However, diff-ing the output with/without the flag showed no differences so just stopped using it. Dropping unnecessary/unused flags might make the process faster.
– GuruM
Dec 21 '14 at 6:49
5
The--exc-c14noption specifies sorting of the attributes. In your specific files the attributes probably were already sorted, but the general advice would be to use the combination--format --exc-c14n.
– ᴠɪɴᴄᴇɴᴛ
Dec 22 '14 at 14:33
add a comment |
In my casetwo.xmlwas generated fromone.xmlby a script. So I just needed to check what was added/removed by the script.
– GuruM
Aug 8 '12 at 10:36
This was the option I needed. Supposedly the most canonical version can be obtained by combining--formatwith--exc-c14n; will probably be still slower to process :(
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:05
It's been quite some time since I wrote the answer, but I faintly remember using the --exc-c14n flag. However, diff-ing the output with/without the flag showed no differences so just stopped using it. Dropping unnecessary/unused flags might make the process faster.
– GuruM
Dec 21 '14 at 6:49
5
The--exc-c14noption specifies sorting of the attributes. In your specific files the attributes probably were already sorted, but the general advice would be to use the combination--format --exc-c14n.
– ᴠɪɴᴄᴇɴᴛ
Dec 22 '14 at 14:33
In my case
two.xml was generated from one.xml by a script. So I just needed to check what was added/removed by the script.– GuruM
Aug 8 '12 at 10:36
In my case
two.xml was generated from one.xml by a script. So I just needed to check what was added/removed by the script.– GuruM
Aug 8 '12 at 10:36
This was the option I needed. Supposedly the most canonical version can be obtained by combining
--format with --exc-c14n; will probably be still slower to process :(– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:05
This was the option I needed. Supposedly the most canonical version can be obtained by combining
--format with --exc-c14n; will probably be still slower to process :(– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:05
It's been quite some time since I wrote the answer, but I faintly remember using the --exc-c14n flag. However, diff-ing the output with/without the flag showed no differences so just stopped using it. Dropping unnecessary/unused flags might make the process faster.
– GuruM
Dec 21 '14 at 6:49
It's been quite some time since I wrote the answer, but I faintly remember using the --exc-c14n flag. However, diff-ing the output with/without the flag showed no differences so just stopped using it. Dropping unnecessary/unused flags might make the process faster.
– GuruM
Dec 21 '14 at 6:49
5
5
The
--exc-c14n option specifies sorting of the attributes. In your specific files the attributes probably were already sorted, but the general advice would be to use the combination --format --exc-c14n.– ᴠɪɴᴄᴇɴᴛ
Dec 22 '14 at 14:33
The
--exc-c14n option specifies sorting of the attributes. In your specific files the attributes probably were already sorted, but the general advice would be to use the combination --format --exc-c14n.– ᴠɪɴᴄᴇɴᴛ
Dec 22 '14 at 14:33
add a comment |
Diffxml gets the basic functionality correct, though it doesn't seem to offer many options for configuration.
Edit: Project Diffxml has been migrated to GitHub since 2013.
It's not quite there yet, but it looks promising at least.
– qedi
Dec 7 '09 at 17:02
not useful for large files though, died after eating 40GB (RAM + SWAP) when comparing two files ~20k lines each
– meta
Oct 26 '17 at 6:27
note that project appears to be dead, with last update in 2013
– Mateusz Konieczny
Oct 9 '18 at 7:53
add a comment |
Diffxml gets the basic functionality correct, though it doesn't seem to offer many options for configuration.
Edit: Project Diffxml has been migrated to GitHub since 2013.
It's not quite there yet, but it looks promising at least.
– qedi
Dec 7 '09 at 17:02
not useful for large files though, died after eating 40GB (RAM + SWAP) when comparing two files ~20k lines each
– meta
Oct 26 '17 at 6:27
note that project appears to be dead, with last update in 2013
– Mateusz Konieczny
Oct 9 '18 at 7:53
add a comment |
Diffxml gets the basic functionality correct, though it doesn't seem to offer many options for configuration.
Edit: Project Diffxml has been migrated to GitHub since 2013.
Diffxml gets the basic functionality correct, though it doesn't seem to offer many options for configuration.
Edit: Project Diffxml has been migrated to GitHub since 2013.
edited Jan 15 at 15:23
stefan123t
33
33
answered Dec 7 '09 at 16:57
dsolimanodsolimano
2,65321835
2,65321835
It's not quite there yet, but it looks promising at least.
– qedi
Dec 7 '09 at 17:02
not useful for large files though, died after eating 40GB (RAM + SWAP) when comparing two files ~20k lines each
– meta
Oct 26 '17 at 6:27
note that project appears to be dead, with last update in 2013
– Mateusz Konieczny
Oct 9 '18 at 7:53
add a comment |
It's not quite there yet, but it looks promising at least.
– qedi
Dec 7 '09 at 17:02
not useful for large files though, died after eating 40GB (RAM + SWAP) when comparing two files ~20k lines each
– meta
Oct 26 '17 at 6:27
note that project appears to be dead, with last update in 2013
– Mateusz Konieczny
Oct 9 '18 at 7:53
It's not quite there yet, but it looks promising at least.
– qedi
Dec 7 '09 at 17:02
It's not quite there yet, but it looks promising at least.
– qedi
Dec 7 '09 at 17:02
not useful for large files though, died after eating 40GB (RAM + SWAP) when comparing two files ~20k lines each
– meta
Oct 26 '17 at 6:27
not useful for large files though, died after eating 40GB (RAM + SWAP) when comparing two files ~20k lines each
– meta
Oct 26 '17 at 6:27
note that project appears to be dead, with last update in 2013
– Mateusz Konieczny
Oct 9 '18 at 7:53
note that project appears to be dead, with last update in 2013
– Mateusz Konieczny
Oct 9 '18 at 7:53
add a comment |
If you wish to also ignore the order of child elements, I wrote a simple python tool for this called xmldiffs:
Compare two XML files, ignoring element and attribute order.
Usage:
xmldiffs [OPTION] FILE1 FILE2
Any extra options are passed to the
diffcommand.
Get it at https://github.com/joh/xmldiffs
add a comment |
If you wish to also ignore the order of child elements, I wrote a simple python tool for this called xmldiffs:
Compare two XML files, ignoring element and attribute order.
Usage:
xmldiffs [OPTION] FILE1 FILE2
Any extra options are passed to the
diffcommand.
Get it at https://github.com/joh/xmldiffs
add a comment |
If you wish to also ignore the order of child elements, I wrote a simple python tool for this called xmldiffs:
Compare two XML files, ignoring element and attribute order.
Usage:
xmldiffs [OPTION] FILE1 FILE2
Any extra options are passed to the
diffcommand.
Get it at https://github.com/joh/xmldiffs
If you wish to also ignore the order of child elements, I wrote a simple python tool for this called xmldiffs:
Compare two XML files, ignoring element and attribute order.
Usage:
xmldiffs [OPTION] FILE1 FILE2
Any extra options are passed to the
diffcommand.
Get it at https://github.com/joh/xmldiffs
answered Mar 22 '17 at 23:59
johjoh
1,175173
1,175173
add a comment |
add a comment |
I use Beyond Compare to compare all types of text based files. They produce versions for Windows and Linux.
1
Plain text comparisons would say the two lines differed, whereas the OP wants them to be reported as the same.
– ChrisF
Dec 7 '09 at 16:33
4
i.e. Canonically compare the XML.
– Chris W. Rea
Dec 9 '09 at 20:08
1
Beyond Compare really sucks for this. It seems to just not be aware of XML elements and do mostly just text comparison.
– Rob K
May 23 '16 at 17:54
add a comment |
I use Beyond Compare to compare all types of text based files. They produce versions for Windows and Linux.
1
Plain text comparisons would say the two lines differed, whereas the OP wants them to be reported as the same.
– ChrisF
Dec 7 '09 at 16:33
4
i.e. Canonically compare the XML.
– Chris W. Rea
Dec 9 '09 at 20:08
1
Beyond Compare really sucks for this. It seems to just not be aware of XML elements and do mostly just text comparison.
– Rob K
May 23 '16 at 17:54
add a comment |
I use Beyond Compare to compare all types of text based files. They produce versions for Windows and Linux.
I use Beyond Compare to compare all types of text based files. They produce versions for Windows and Linux.
answered Dec 7 '09 at 16:30
AlanAlan
17617
17617
1
Plain text comparisons would say the two lines differed, whereas the OP wants them to be reported as the same.
– ChrisF
Dec 7 '09 at 16:33
4
i.e. Canonically compare the XML.
– Chris W. Rea
Dec 9 '09 at 20:08
1
Beyond Compare really sucks for this. It seems to just not be aware of XML elements and do mostly just text comparison.
– Rob K
May 23 '16 at 17:54
add a comment |
1
Plain text comparisons would say the two lines differed, whereas the OP wants them to be reported as the same.
– ChrisF
Dec 7 '09 at 16:33
4
i.e. Canonically compare the XML.
– Chris W. Rea
Dec 9 '09 at 20:08
1
Beyond Compare really sucks for this. It seems to just not be aware of XML elements and do mostly just text comparison.
– Rob K
May 23 '16 at 17:54
1
1
Plain text comparisons would say the two lines differed, whereas the OP wants them to be reported as the same.
– ChrisF
Dec 7 '09 at 16:33
Plain text comparisons would say the two lines differed, whereas the OP wants them to be reported as the same.
– ChrisF
Dec 7 '09 at 16:33
4
4
i.e. Canonically compare the XML.
– Chris W. Rea
Dec 9 '09 at 20:08
i.e. Canonically compare the XML.
– Chris W. Rea
Dec 9 '09 at 20:08
1
1
Beyond Compare really sucks for this. It seems to just not be aware of XML elements and do mostly just text comparison.
– Rob K
May 23 '16 at 17:54
Beyond Compare really sucks for this. It seems to just not be aware of XML elements and do mostly just text comparison.
– Rob K
May 23 '16 at 17:54
add a comment |
Our SD Smart Differencer compares documents based on structure as opposed to actual layout.
There's an XML Smart Differencer. For XML, that means matching order of tags and content. It should note that the text string in the specific fragment you indicated was different. It presently doesn't understand the XML notion of tag attributes indicating whether
whitespace is normalized vs. significant.
In your SO profile you provide full disclosure about your employer; I'd have preferred a short disclaimer inside your answer as well :) BTW, I tried to download an evaluation copy, but the request form is 'smart' (via JS) enough to disable the combination XML with Smart Differencer (also the latter in combination with Python, although possible according to the SD product page)?
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:03
1
Ah. Thanks for the reminder. This is an answer from a time before there was a clear SO policy on this. I'm revising the answer to signal the relationship in SO policy compliant answer.
– Ira Baxter
Nov 27 '14 at 15:52
I'll check the download page; not all of our live products make into that list. Yes, these exist.
– Ira Baxter
Nov 27 '14 at 15:53
I checked the download page. Yes, the XML smart differencer is not there. I'll have the back-room guys work on fixing that; should be there in 1-2 weeks at most (they have a backlog, don't we all?) In meantime, if you want to try it, send email (see bio).
– Ira Baxter
Jan 26 '15 at 20:16
1
Linked page has no word "XML" in it.
– Mateusz Konieczny
Oct 9 '18 at 7:52
|
show 1 more comment
Our SD Smart Differencer compares documents based on structure as opposed to actual layout.
There's an XML Smart Differencer. For XML, that means matching order of tags and content. It should note that the text string in the specific fragment you indicated was different. It presently doesn't understand the XML notion of tag attributes indicating whether
whitespace is normalized vs. significant.
In your SO profile you provide full disclosure about your employer; I'd have preferred a short disclaimer inside your answer as well :) BTW, I tried to download an evaluation copy, but the request form is 'smart' (via JS) enough to disable the combination XML with Smart Differencer (also the latter in combination with Python, although possible according to the SD product page)?
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:03
1
Ah. Thanks for the reminder. This is an answer from a time before there was a clear SO policy on this. I'm revising the answer to signal the relationship in SO policy compliant answer.
– Ira Baxter
Nov 27 '14 at 15:52
I'll check the download page; not all of our live products make into that list. Yes, these exist.
– Ira Baxter
Nov 27 '14 at 15:53
I checked the download page. Yes, the XML smart differencer is not there. I'll have the back-room guys work on fixing that; should be there in 1-2 weeks at most (they have a backlog, don't we all?) In meantime, if you want to try it, send email (see bio).
– Ira Baxter
Jan 26 '15 at 20:16
1
Linked page has no word "XML" in it.
– Mateusz Konieczny
Oct 9 '18 at 7:52
|
show 1 more comment
Our SD Smart Differencer compares documents based on structure as opposed to actual layout.
There's an XML Smart Differencer. For XML, that means matching order of tags and content. It should note that the text string in the specific fragment you indicated was different. It presently doesn't understand the XML notion of tag attributes indicating whether
whitespace is normalized vs. significant.
Our SD Smart Differencer compares documents based on structure as opposed to actual layout.
There's an XML Smart Differencer. For XML, that means matching order of tags and content. It should note that the text string in the specific fragment you indicated was different. It presently doesn't understand the XML notion of tag attributes indicating whether
whitespace is normalized vs. significant.
edited Nov 27 '14 at 15:52
answered May 23 '10 at 5:01
Ira BaxterIra Baxter
1941318
1941318
In your SO profile you provide full disclosure about your employer; I'd have preferred a short disclaimer inside your answer as well :) BTW, I tried to download an evaluation copy, but the request form is 'smart' (via JS) enough to disable the combination XML with Smart Differencer (also the latter in combination with Python, although possible according to the SD product page)?
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:03
1
Ah. Thanks for the reminder. This is an answer from a time before there was a clear SO policy on this. I'm revising the answer to signal the relationship in SO policy compliant answer.
– Ira Baxter
Nov 27 '14 at 15:52
I'll check the download page; not all of our live products make into that list. Yes, these exist.
– Ira Baxter
Nov 27 '14 at 15:53
I checked the download page. Yes, the XML smart differencer is not there. I'll have the back-room guys work on fixing that; should be there in 1-2 weeks at most (they have a backlog, don't we all?) In meantime, if you want to try it, send email (see bio).
– Ira Baxter
Jan 26 '15 at 20:16
1
Linked page has no word "XML" in it.
– Mateusz Konieczny
Oct 9 '18 at 7:52
|
show 1 more comment
In your SO profile you provide full disclosure about your employer; I'd have preferred a short disclaimer inside your answer as well :) BTW, I tried to download an evaluation copy, but the request form is 'smart' (via JS) enough to disable the combination XML with Smart Differencer (also the latter in combination with Python, although possible according to the SD product page)?
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:03
1
Ah. Thanks for the reminder. This is an answer from a time before there was a clear SO policy on this. I'm revising the answer to signal the relationship in SO policy compliant answer.
– Ira Baxter
Nov 27 '14 at 15:52
I'll check the download page; not all of our live products make into that list. Yes, these exist.
– Ira Baxter
Nov 27 '14 at 15:53
I checked the download page. Yes, the XML smart differencer is not there. I'll have the back-room guys work on fixing that; should be there in 1-2 weeks at most (they have a backlog, don't we all?) In meantime, if you want to try it, send email (see bio).
– Ira Baxter
Jan 26 '15 at 20:16
1
Linked page has no word "XML" in it.
– Mateusz Konieczny
Oct 9 '18 at 7:52
In your SO profile you provide full disclosure about your employer; I'd have preferred a short disclaimer inside your answer as well :) BTW, I tried to download an evaluation copy, but the request form is 'smart' (via JS) enough to disable the combination XML with Smart Differencer (also the latter in combination with Python, although possible according to the SD product page)?
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:03
In your SO profile you provide full disclosure about your employer; I'd have preferred a short disclaimer inside your answer as well :) BTW, I tried to download an evaluation copy, but the request form is 'smart' (via JS) enough to disable the combination XML with Smart Differencer (also the latter in combination with Python, although possible according to the SD product page)?
– ᴠɪɴᴄᴇɴᴛ
Nov 27 '14 at 14:03
1
1
Ah. Thanks for the reminder. This is an answer from a time before there was a clear SO policy on this. I'm revising the answer to signal the relationship in SO policy compliant answer.
– Ira Baxter
Nov 27 '14 at 15:52
Ah. Thanks for the reminder. This is an answer from a time before there was a clear SO policy on this. I'm revising the answer to signal the relationship in SO policy compliant answer.
– Ira Baxter
Nov 27 '14 at 15:52
I'll check the download page; not all of our live products make into that list. Yes, these exist.
– Ira Baxter
Nov 27 '14 at 15:53
I'll check the download page; not all of our live products make into that list. Yes, these exist.
– Ira Baxter
Nov 27 '14 at 15:53
I checked the download page. Yes, the XML smart differencer is not there. I'll have the back-room guys work on fixing that; should be there in 1-2 weeks at most (they have a backlog, don't we all?) In meantime, if you want to try it, send email (see bio).
– Ira Baxter
Jan 26 '15 at 20:16
I checked the download page. Yes, the XML smart differencer is not there. I'll have the back-room guys work on fixing that; should be there in 1-2 weeks at most (they have a backlog, don't we all?) In meantime, if you want to try it, send email (see bio).
– Ira Baxter
Jan 26 '15 at 20:16
1
1
Linked page has no word "XML" in it.
– Mateusz Konieczny
Oct 9 '18 at 7:52
Linked page has no word "XML" in it.
– Mateusz Konieczny
Oct 9 '18 at 7:52
|
show 1 more comment
Not sure whether (the dependence of) an online tool counts as a solution but, for what it's worth, I got good result in this online XML comparison tool. It simply works.
add a comment |
Not sure whether (the dependence of) an online tool counts as a solution but, for what it's worth, I got good result in this online XML comparison tool. It simply works.
add a comment |
Not sure whether (the dependence of) an online tool counts as a solution but, for what it's worth, I got good result in this online XML comparison tool. It simply works.
Not sure whether (the dependence of) an online tool counts as a solution but, for what it's worth, I got good result in this online XML comparison tool. It simply works.
answered Aug 8 '17 at 18:24
RayLuoRayLuo
1315
1315
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f79920%2fhow-can-i-diff-two-xml-files%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown