このxmlファイルがある場合:
<root>
<node id="a">
<section id="a_1">
<item id="0">
<attribute>
<color>Red</color>
</attribute>
</item>
</section>
<section id="a_2">
<item id="0">
<attribute>
<color>Red</color>
</attribute>
</item>
</section>
</node>
<node id="b">
<section id="b_1">
<user id="b_1a">
<attribute>
<name>John</name>
</attribute>
</user>
<user id="b_1b">
<attribute>a</attribute>
</user>
</section>
<section id="b_1" method="create">
<user id="b_1a">
<attribute>
<name>John</name>
</attribute>
</user>
<user id="b_1c">
<attribute>a</attribute>
</user>
</section>
<section id="b_2">
<user id="b_1a">
<attribute>
<name>John</name>
</attribute>
</user>
</section>
</node>
</root>
そして、私は出力を次のようにしたいと思います:
<root>
<node id="a">
<section id="a_1">
<item id="0">
<attribute>
<color>Red</color>
</attribute>
</item>
</section>
<section id="a_2">
<item id="0">
<attribute>
<color>Red</color>
</attribute>
</item>
</section>
</node>
<node id="b">
<section id="b_1">
<user id="b_1a">
<attribute>
<name>John</name>
</attribute>
</user>
<user id="b_1b">
<attribute>a</attribute>
</user>
</section>
<section id="b_1" method="create">
<user id="b_1c">
<attribute>a</attribute>
</user>
</section>
<section id="b_2">
<user id="b_1a">
<attribute>
<name>John</name>
</attribute>
</user>
</section>
</node>
</root>
IDが同じである限り、追加のメソッドがある場合でも、1つのセクションIDと見なされます。したがって、「メソッド作成」が含まれている2番目のセクションID(b_1)のユーザーID(b_1a)を削除します。これは本当に私を苛立たせます、そして私は方法を省略することができませんでした。ですので、どんな助けでも大歓迎です。セクションIDb_2を見ると、同じユーザーID b_1と同じ「John」がありますが、セクションIDが異なるため、削除しません。したがって、基本的にはセクションIDに基づいて比較します。
PS:要素は、必ずしもユーザーまたはセクションである必要はありませんが、IDが同じである限り何でもかまいません。
どうもありがとう。
よろしく、ジョン