Formatting an XML string in C#
Here’s a nifty trick if you’ve got a chunk of XML you want to format nicely:
XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(xmlStringVariable); MemoryStream memoryStream = new MemoryStream(10240); xmldoc.Save(memoryStream); string formattedXml = Encoding.ASCII.GetString(memoryStream.GetBuffer()); memoryStream.Close();







Comments