LINQ to XML Newbie: перемещение узлов с одного узла на другой
Приветствую!
У меня есть объект XElement, который содержит следующее:
<Root>
<SubSections>
<SubSection id="A">
<Foo id="1">
<Bar />
<Bar />
<Bar />
</Foo>
<Foo id="2">
<Bar />
<Bar />
</Foo>
<Foo id="3">
<Bar />
</Foo>
</SubSection>
<SubSection id="B">
<Foo id="4">
<Bar />
<Bar />
<Bar />
</Foo>
<Foo id="5">
<Bar />
<Bar />
</Foo>
</SubSection>
<SubSection id="C">
</SubSection>
</SubSections>
</Root>
Я хотел бы переместить Foo's 2 и 3 в SubSection с идентификатором «C», так что результат будет:
<Root>
<SubSections>
<SubSection id="A">
<Foo id="1">
<Bar />
<Bar />
<Bar />
</Foo>
</SubSection>
<SubSection id="B">
<Foo id="4">
<Bar />
<Bar />
<Bar />
</Foo>
<Foo id="5">
<Bar />
<Bar />
</Foo>
</SubSection>
<SubSection id="C">
<Foo id="2">
<Bar />
<Bar />
</Foo>
<Foo id="3">
<Bar />
</Foo>
</SubSection>
</SubSections>
</Root>
Как лучше всего перенести разделы Foo «2» и «3» в подраздел «C»?