假设我有一些像这样的xml:
<root>
<object id='1'/>
<object id='1' otherid='2'/>
<object otherid='2'/>
<object otherid='2' yetanotherid='3'/>
<object yetanotherid='3'/>
<object id='2'>I'm not the same</object>
</root>
可爱,我知道。现在这些都是相同的对象,但它们有各种各样的ID。我怎么组他们?任何这些id都将唯一标识,所以id [1] = otherid [2] = yetanotherid [3]。
一个完整的例子:
<root>
<object id='1'><property1></property1></object>
<object id='1' otherid='2'><property1></property1></object>
<object otherid='2'><property2></property2></object>
<object otherid='2' yetanotherid='3'><property3></property3></object>
<object yetanotherid='3'><property2></property2><property4></property4></object>
<object id='2'><property2></property2></object>
</root>
结果:
<root>
<object id='1' otherid='2' yetanotherid='3'>
<property1></property1>
<property2></property2>
<property3></property3>
<property4></property4>
</object>
<object id='2'>
<property2></property2>
</object>
</root>