Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java中的节点比较与替换_Java_Xml_Spring_Dom_Xml Parsing - Fatal编程技术网

Java中的节点比较与替换

Java中的节点比较与替换,java,xml,spring,dom,xml-parsing,Java,Xml,Spring,Dom,Xml Parsing,我想比较两个XML文件“parent.XML”、“child.XML”, 然后检查节点是否存在于“parent.xml”中,而不存在于“child.xml”中,然后将这些节点添加到“child.xml”中,它应该维护节点层次结构 “Parent.xml”的结构 居中 无效的 #909090 25 符合事实的 http://www.saama.com 第六 海图网 http://eee.example.com 约翰·多伊 xyz@example.com 麻省理工学院 “child.xml”

我想比较两个XML文件“parent.XML”、“child.XML”, 然后检查节点是否存在于“parent.xml”中,而不存在于“child.xml”中,然后将这些节点添加到“child.xml”中,它应该维护节点层次结构

“Parent.xml”的结构


居中
无效的
#909090 
25
符合事实的
http://www.saama.com
第六
海图网
http://eee.example.com
约翰·多伊
xyz@example.com
麻省理工学院

“child.xml”的结构


[function]function(){返回this.point.name+“-”+this.percentage;}[/function]
[function]function(event){getAjaxData(“ajax/piedill.json”,this,event)}[/function]
http://eee.example.com
约翰·多伊
在“parent.xml”中,我们可以看到节点图例存在,但不在child中,因此应将其添加到“child.xml”中

第二个节点许可证存在于两个xml文件中,但在“child.xml”中缺少几个节点,因此我们可以添加缺少的节点,并且它应该保持相同的层次结构


可以有n级嵌套,XML文件的格式也不固定,它可以随时更改

我想这就是DOM解析的目的,对吗?你试过了吗?我已经完成了添加第一级节点的工作,我面临着比较节点层次结构和递归添加的问题。
<chart>
<chartconf alignTicks="true" animation="true" backgroundColor="#FFFFFF" 
       borderColor="#4572A7" borderRadius="5" borderWidth="0" className="" defaultSeriesType="">
</chartconf>
<legend>
    <align>center</align>
    <backgroundColor>null</backgroundColor>
    <borderColor>#909090</borderColor> 
    <borderRadius>25</borderRadius>
</legend>
<credits>
    <enabled>true</enabled>
    <position></position>
    <href>http://www.saama.com</href>
    <style bek="5555s">Sixth</style>
    <text>Highcharts.com</text>
</credits>
<license>
    <info>
        <url>http://eee.example.com</url>
        <author>Jhon Doe</author>
        <email>xyz@example.com</email>
        <type>GNU, MIT dual</type>
    </info>
</license>
<chart renderTo="pieContainer" >
<title align="center" text="Test Title" style="" verticalAlign=""></title>
<credits enabled="false" position="" href="" style="" text=""></credits>

<tooltip>
    <formatter>[function]function() {return this.point.name + " - " + this.percentage;}[/function]</formatter>
</tooltip>
<exporting enabled="true"></exporting>
<plotOptions>
    <pie allowPointSelect="true" cursor="pointer">
        <dataLabels align="left" enabled="true"></dataLabels>
        <series cursor="pointer" allowPointSelect="true">
            <events>
                <click>[function]function(event) {getAjaxData("ajax/pieDrill.json", this, event)}[/function]</click>
            </events>
        </series>
    </pie>
</plotOptions>

<license>
    <info>
        <url>http://eee.example.com</url>
        <author>Jhon Doe</url>
    </info>
</license></chart>