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
Post a Comment