a.xml,无子节点
<?xml version= "1.0 " standalone= "yes "?>
<Structrue>
<Departments>
<Department DWBM= "115600200101 " SJDWBM= "geotech "/>
<Department DWBM= "100300200601 " SJDWBM= "115600200101 " />
<Department DWBM= "200000200601 " SJDWBM= "115600200101 " />
<Department DWBM= "100300200601 " SJDWBM= "115600200101 " />
<Department DWBM= "200000200601 " SJDWBM= "115600200101 " />
<Department DWBM= "168200200201 " SJDWBM= "100300200601 " />
<Department DWBM= "188700200301 " SJDWBM= "100300200601 " />
<Department DWBM= "188700200302 " SJDWBM= "188700200301 " />
<Department DWBM= "188700200303 " SJDWBM= "188700200301 " />
<Department DWBM= "188700200501 " SJDWBM= "188700200301 " />
<Department DWBM= "151200200301 " SJDWBM= "100300200601 " />
<Department DWBM= "151200200302 " SJDWBM= "151200200301 " />
<Department DWBM= "226600200301 " SJDWBM= "200000200601 " />
<Department DWBM= "226600200401 " SJDWBM= "226600200301 " />
</Departments>
</Structrue>
现在根据 "SJDWBM "和 "DWBM "两个属性值来判断,如果a节点 "SJDWBM "的值和b节点的 "DWBM "值相同,则a节点为b节点的子节点。
最终得到b.xml文件,
b.xml
<?xml version= "1.0 " standalone= "yes "?>
<Structrue>
<Departments>
<Department DWBM= "115600200101 " SJDWBM= "geotech ">
<Department DWBM= "100300200601 " SJDWBM= "115600200101 " >
<Department DWBM= "168200200201 " SJDWBM= "100300200601 " />
<Department DWBM= "188700200301 " SJDWBM= "100300200601 " >
<Department DWBM= "188700200302 " SJDWBM= "188700200301 " />
<Department DWBM= "188700200303 " SJDWBM= "188700200301 " />
<Department DWBM= "188700200501 " SJDWBM= "188700200301 " />
</Department>
<Department DWBM= "151200200301 " SJDWBM= "100300200601 " >
<Department DWBM= "151200200302 " SJDWBM= "151200200301 " />
</Department>
</Department>