用于比较 xml 文件的工具或库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/547399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 12:22:29  来源:igfitidea点击:

Tool or library for comparing xml files

xmlcomparisoncontent-management

提问by joe

I am looking for an XML comparing tool that understands xml. It cannot be a line by line comparision like WinMerge or Beyond Compare.

我正在寻找一个了解 xml 的 XML 比较工具。它不能像 WinMerge 或 Beyond Compare 那样进行逐行比较。

An ideal solution would be one that shows changes similar to the way Word 2007 shows track changes. DeltaXMLdoes this, but does not come with a real GUI 'out of the box' and is $500 per user!:

一种理想的解决方案是显示与 Word 2007 显示跟踪更改的方式类似的更改。 DeltaXML做到了这一点,但没有“开箱即用”的真正 GUI,每位用户 500 美元!:

ExamXmlworks out of the box but displays the differences in a confusing manner. It does not have a concept of before and after, it just shows the differences:

ExamXml开箱即用,但以令人困惑的方式显示差异。它没有前后的概念,它只是显示了差异:

alt text
(source: a7soft.com)

替代文字
(来源:a7soft.com

The tool should have the concept of using attributes as a key, so that it does not think that a reordered list of elements has changed. DeltaXML does this but I failed to set it up correctly for the screen shot.

该工具应该有使用属性作为键的概念,这样它就不会认为重新排序的元素列表发生了变化。DeltaXML 执行此操作,但我未能为屏幕截图正确设置它。



UPDATE:

更新:

So far ExamlXMLis the best out of the box solution. But it lacks the change management concepts of DeltaXML. Resulting in some usability problems.

到目前为止,ExmlXML是最好的开箱即用解决方案。但它缺乏DeltaXML 的变更管理概念。导致一些可用性问题。

DeltaXMLis pretty much the solution I need, but something with more functionality out of the box would be better. DeltaXML requires writing java code to call the api, along with writing XSL to transform the xml into the expected input.

DeltaXML几乎是我需要的解决方案,但具有更多开箱即用功能的东西会更好。DeltaXML 需要编写 java 代码来调用 api,同时编写 XSL 将 xml 转换为预期的输入。

采纳答案by John Virgolino

If I understand your problem, you likely have an application that uses XML files as the data storage and the GUI abstracts the "technical" tag names into "user friendly" labels - again, I am assuming. So it would be a natural extension to view differences in a similar way. I am also assuming your application doesn't have a diff facility that follows the "abstraction" concept.

如果我理解您的问题,您可能有一个使用 XML 文件作为数据存储的应用程序,并且 GUI 将“技术”标签名称抽象为“用户友好”标签——我再次假设。因此,以类似的方式查看差异将是一种自然的延伸。我还假设您的应用程序没有遵循“抽象”概念的差异工具。

I did some searching and found one app (ExamXML) that seems to come close with highlighting features. I downloaded the eval version and tested your files against it:

我做了一些搜索,发现了一个应用程序 ( ExamXML),它似乎具有突出显示的功能。我下载了 eval 版本并针对它测试了您的文件:

http://www.programmedintheusa.com/images/stack547399.png

http://www.programmedintheusa.com/images/stack547399.png

It does a pretty good job of highlighting the differences. It seems pretty interactive and pops up with how many differences. It looks like you can change the colors it uses, so maybe you can use grays and whites to de-emphasize the tags. It also seems to have a lot of options that you can pre-set for your users as well.

它在突出差异方面做得很好。它似乎非常具有交互性,并且会弹出多少差异。看起来你可以改变它使用的颜色,所以也许你可以使用灰色和白色来淡化标签。它似乎也有很多选项,您也可以为您的用户预先设置。

I want to note that you will be hard pressed to find an XML comparison tool that will not show the tag names, as the tags are what give the content context. If you take away context, it becomes difficult to understand the data being displayed. Anyhow, maybe this tool might be helpful. Have you also tried to show your users some of these tools and see what they are willing to tolerate, sometimes they may surprise you. Hope this helps!

我想指出的是,您将很难找到不显示标签名称的 XML 比较工具,因为标签提供了内容上下文。如果去掉上下文,就很难理解所显示的数据。无论如何,也许这个工具可能会有所帮助。您是否也尝试向您的用户展示其中一些工具,看看他们愿意容忍什么,有时他们可能会让您大吃一惊。希望这可以帮助!

回答by Sylverdrag

I am very surprised nobody mentioned Microsoft's XML NotePad

我很惊讶没有人提到微软的XML NotePad

It's free and it can create a pretty good comparison, telling which elements/attributes have changed, moved, been deleted, etc.:

它是免费的,它可以创建一个很好的比较,告诉哪些元素/属性已更改、移动、删除等:

(Sorry if the screenshots are a little wide).

(对不起,如果屏幕截图有点宽)。

You can also apply XLSes to the XML file and do various editing operations. Well worth a try.

您还可以将 XLS 应用到 XML 文件并进行各种编辑操作。非常值得一试。

回答by Mike L

SourceGear's DiffMerge is free for a single-user:

SourceGear 的 DiffMerge 对单用户免费:

http://www.sourcegear.com/diffmerge/

http://www.sourcegear.com/diffmerge/

回答by James Sulak

I might try DeltaXML+ an XSLT transform to get the specific result that you want. One problem with using plain-text compare tools with XML is that the physical form of an XML document (its indenting, etc.) can change even if the content itself doesn't, which could lead to a lot of false positives. DeltaXML is a very good tool for comparing document-based XML.

我可能会尝试使用DeltaXML+ XSLT 转换来获得您想要的特定结果。将纯文本比较工具与 XML 结合使用的一个问题是,即使内容本身没有变化,XML 文档的物理形式(缩进等)也会发生变化,这可能会导致大量误报。DeltaXML 是用于比较基于文档的 XML 的非常好的工具。

Also, depending on the editor your users use, it may have XML differencing built-in. For example, Arbortext Editor has a good tool that shows the text (not the tags) with changes highlighted / struck-through.

此外,根据您的用户使用的编辑器,它可能具有内置的 XML 差异。例如,Arbortext Editor 有一个很好的工具,可以显示带有突出显示/删除线更改的文本(而不是标签)。

回答by jmcecil

Altova diffDogXML Spy and diffDog are exceptional tools. Pry them from my cold dead hands, kinda stuff.

Altova diffDogXML Spy 和 diffDog 是出色的工具。从我冰冷的死手上撬开它们,有点东西。

回答by Matt Jordan

Beyond Compare is excellent as @BobbyShaftoe has already mentioned. For merging however, I like to use Araxis Merge. We use it for similar purposes quite often.

正如@BobbyShaftoe 已经提到的那样,Beyond Compare 非常出色。但是,对于合并,我喜欢使用Araxis Merge。我们经常将它用于类似目的。

As far as your comment about the nontechnical ability of your users:

至于您对用户的非技术能力的评论:

Thanks for the Responses... But these all seem too technical. My users normally do not see the xml tags because their XML authoring tool abstracts them away. Are there any tools that display differences in the text content, but do not show (or de-emphazise) the xml tags.

感谢您的答复...但这些似乎都太技术性了。我的用户通常看不到 xml 标签,因为他们的 XML 创作工具将它们抽象出来。是否有任何工具可以显示文本内容的差异,但不显示(或不强调)xml 标签。

I'm going to throw this out there: your users should learn. If you have them merging and changing XML files - I'm assuming potentially for record keeping or application configuration - then they should have at least a rudimentary understanding of what they're doing. They don't have to be XML whizzes to use the tools listed and get the job done.

我要把这个扔出去:你的用户应该学习。如果您让他们合并和更改 XML 文件 - 我假设可能用于记录保存或应用程序配置 - 那么他们至少应该对他们在做什么有一个基本的了解。他们不必是 XML 专家也能使用列出的工具并完成工作。

If, however, requiring your users to have a rudimentary knowledge of the job they are doing is impossible, then I would suggest writing a configuration utility yourself and delivering it for your end users, rather than relying on 3rd party software.

但是,如果要求您的用户对他们正在做的工作有基本的了解是不可能的,那么我建议您自己编写一个配置实用程序并将其交付给您的最终用户,而不是依赖 3rd 方软件。

回答by Aussie Craig

Try XML Notepad from Microsoft MSDN XMLit has a compare XML files. No idea how good it is.

从 Microsoft MSDN XML尝试 XML Notepad它有一个比较 XML 文件。不知道有多好。

回答by Ray Lu

Either programatically or UI, you can use XmlDiff, XmlPatch tools and library from MSDN For details how it work, check out the guide.

无论以编程方式还是 UI,您都可以使用 MSDN 中的 XmlDiff、XmlPatch 工具和库。有关其工作原理的详细信息,请查看指南。

http://msdn.microsoft.com/en-us/library/aa302294.aspx

http://msdn.microsoft.com/en-us/library/aa302294.aspx

回答by Dan Blanchard

You may find The XML Diff and Patch GUI Tool(sample code on MSDN) meets your needs a little better: it still shows tags, but emphasizes the difference in text. Since you get the code, for a little more effort you could tailor it more precisely to your requirements.

您可能会发现The XML Diff and Patch GUI Tool(MSDN 上的示例代码)更能满足您的需求:它仍然显示标签,但强调了文本的差异。由于您获得了代码,因此只需付出更多努力,您就可以更精确地根据您的要求对其进行定制。

Although the sample is relatively elderly (July 2004, and has its roots in 2002) it upgrades to Visual Studio Express C# 2008 painlessly. Don't be put off when downloading the samplefrom the MSDN site if/when the installer MSI mentions "SQLXML Bulkload in .NET Code Sample" - it's not!

尽管示例相对较旧(2004 年 7 月,起源于 2002 年),但它可以轻松升级到 Visual Studio Express C# 2008。如果/当安装程序 MSI 提到“.NET 代码示例中的 SQLXML Bulkload”时,请不要在从 MSDN 站点下载示例时推迟- 事实并非如此!

回答by Christophe Herreman

Have you tried examdiff? Of course it's still a tech tool, but it's easy to work with. It has a drag and drop interface to compare files.

你试过Examdiff吗?当然,它仍然是一种技术工具,但很容易使用。它有一个拖放界面来比较文件。