Add Parent level to XML with Linq

A

Avi

Hi all,



I'm using Linq and would like to encapsulate my xml with an additional
parent level.



My XML

<Collection>

<ChildCollection>

</ChildCollection>

</Collection>



The XML I want with an additional parent level



<CollectionParent>

<Collection>

<ChildCollection>

</ChildCollection>

</Collection>

</CollectionParent>



What is the command to do that?



Thanks,

Avi
 
M

Martin Honnen

Avi said:
What is the command to do that?

Simply create a new XElement and pass the other in e.g.

XElement col = XElement.Parse(@"<Collection>

<ChildCollection>

</ChildCollection>

</Collection>");
XElement colPar = new XElement("CollectionParent", col);
 
A

Avi

Thanks,

Martin Honnen said:
Simply create a new XElement and pass the other in e.g.

XElement col = XElement.Parse(@"<Collection>

<ChildCollection>

</ChildCollection>

</Collection>");
XElement colPar = new XElement("CollectionParent", col);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top