Hi,
I've got a XmlDocument and I want to get the Content (OuterXml) as a pretty printed string. How can I do this?
Regards
Hi,
I've got a XmlDocument and I want to get the Content (OuterXml) as a pretty printed string. How can I do this?
Regards
There are many text editors that can accomplish this either out of the box or with an addon. I know there's an addon out there for TextPad and one for Notepad++. You can just copy the OuterXml property as a string, paste into the text editor and the add-on will do the rest. If you are wanting to do this with code, the XmlWriter class can be used in conjunction with a FileStream to write it to disk.
Assuming I understand this correctly
using System.Xml.Linq;
XDocument xDoc = XDocument.Load(@".....\test.xml");
string xDocString = xDoc.ToString(SaveOptions.None);
Or you can use this link: Attractively format the XML with consistant indentation