Java:比较两个XML的最简单方法

Java:比较两个XML的最简单方法,java,xml,Java,Xml,我有两个XML: first.xml <text>This is text</text> <output>This is output</output> second.xml <text>This is not text</text> <output>This is output</output> first.xml 这是文本 这是输出 second.xml 这不是文本 这是输出 我想比较这

我有两个XML:

first.xml

<text>This is text</text>
<output>This is output</output>

second.xml

<text>This is not text</text>
<output>This is output</output>
first.xml
这是文本
这是输出
second.xml
这不是文本
这是输出
我想比较这两个XML,输出应该是这样的

<text>This is <inserted>not</inserted> text</text>
    <output>This is output</output>
这不是文本
这是输出
意思是,我想在新添加的文本中添加一个新的标记。 如何比较这些XML并创建新的XML

谢谢您的时间:)

看看。


在单元测试中使用很好,非常好的输出。

我不认为这是一个复制品,因为原来的问题是3年前的1/2年,并且解决方案()没有在超过2年内发布。同样,我也不会考虑使用单元测试库来解决编程问题。为什么你认为这个问题是关于测试的?这就是所谓的重复的答案,是一个两年多没有发布过的库。因为我认为比较两个XML文件是否相同就像测试两个XML文件是否相同一样same@Farmor-问题的主体清楚地表明OP需要XML文档之间的差异。。。不仅仅是回答是/否。