Vignesh Kumar

Vignesh Kumar

  • NA
  • 1k
  • 403.7k

Add string to xml file at the beginning

Oct 27 2016 4:40 AM

Hi,

I have an xml file with this contents.

XDocumentnewXML = XDocument.Load(newStringReader(xmlDetail));

<Info>
<Details>
<ID>Ryan</ID>
</Details>
<Details>
<ID>Danny</ID>
</Details>
< /Info>

stringaddRootElements = @"<?xml version=""1.0"" encoding=""utf-8""?>";

Now how can I add the above string to the beginning of the xml.

So my XML should like below.

<?xml version=""1.0"" encoding=""utf-8""?>
< Info>
<Details>
<ID>Ryan</ID>
</Details>
<Details>
<ID>Danny</ID>
</Details>
< /Info>


Answers (2)