xml - C# Adding a root to an XDocument -


i have string contains xml, lets this:

<novels>   <book>   <title>cat in hat</title>   <price>12</price>  </book> </novels> 

i want make xdocument looks this:

<booklist>  <novels>    <book>    <title>cat in hat</title>    <price>12</price>   </book>  </novels> </booklist> 

i can load xml string xdocument using xdocument doc = xdocument.parse(xmlstring);

how load document under new root. can think of creating new xdocument root want , using loop add nodes children, there easier way of doing this?

xdocument yourresult = new xdocument(new xelement("booklist", doc.root)); 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -