我有相同類型的2 XML元素(來自不同的XML文檔具有相同的架構)看起來像這樣:在C#相同類型的合併XML節點
<Parent>
<ChildType1>contentA</ChildType1>
<ChildType2>contentB</ChildType2>
<ChildType3>contentC</ChildType3>
</Parent>
<Parent>
<ChildType1>contentD</ChildType1>
<ChildType3>contentE</ChildType3>
</Parent>
元素類型ChildType1,ChildType2和ChildType3可以具有父元素中最多隻有一個實例。
我需要做的是與第一父節點的第二父節點的內容到一個新的節點,將這個樣子合併:
<Parent>
<ChildType1>contentD</ChildType1>
<ChildType2>contentB</ChildType2>
<ChildType3>contentE</ChildType3>
</Parent>
您不希望第二個節點複製到第一個,要覆蓋第一與第二。或者你的樣本結果是錯誤的。 –
覆蓋節點意味着結果將不包含元素。但我同意,複製也不是那裏最好的術語。 –
vicch