コード例 #1
0
        public static string Normalize(XContainer xml)
        {
            using (var stringWriter = new StringWriter())
            {
                var settings = new XmlWriterSettings {Indent = true};

                using (var xmlTextWriter = XmlWriter.Create(stringWriter, settings))
                {
                    xml.WriteTo(xmlTextWriter);
                    xmlTextWriter.Flush();
                    return stringWriter.GetStringBuilder().ToString();
                }
            }
        }