All pastes #64253 Raw Edit

Something

public text v1 · immutable
#64253 ·published 2006-06-11 12:24 UTC
rendered paste body
static string DocumentToText(XmlDocument document)
        {
            MemoryStream stream = new MemoryStream();           
            XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8);              
            writer.Formatting = Formatting.Indented;
          
            writer.WriteStartDocument();

            document.WriteTo(writer);    
    
            writer.WriteEndDocument();
            writer.Flush();

            UTF8Encoding encoding = new UTF8Encoding();
            return encoding.GetString(stream.ToArray());           
        }