コード例 #1
0
 // This is apapted from http://stackoverflow.com/questions/6442123/in-c-how-do-i-convert-a-xmlnode-to-string-with-indentation-without-looping
 // Note that it currently outputs the string as UTF-16 rather than the roar default of UTF-8
 // But since its only for debugging that shouldn't matter too much.
 public static string DebugAsString(this System.Xml.XmlNode node)
 {
     using (var sw = new System.IO.StringWriter())
     {
         using (var xw = new System.Xml.XmlTextWriter(sw))
         {
             xw.Formatting  = System.Xml.Formatting.Indented;
             xw.Indentation = 4;
             node.WriteTo(xw);
         }
         return(sw.ToString());
     }
 }
コード例 #2
0
 public static string AsString(this System.Xml.XmlNode node)
 {
     using (var swriter = new StringWriter())
     {
         using (var twriter = new System.Xml.XmlTextWriter(swriter))
         {
             twriter.Formatting  = System.Xml.Formatting.Indented;
             twriter.Indentation = 3;
             twriter.QuoteChar   = '\'';
             node.WriteTo(twriter);
         }
         return(swriter.ToString());
     }
 }