今天在写一个工具时候突然用到了Xml,并且要输出到TextBox中,于是就写了一下啊,上网一看还挺多人问这问题,于是晒一下@_@!
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
XmlTextWriter writer = new XmlTextWriter(sw);
writer.Formatting = Formatting.Indented;
writer.Indentation = 4;
writer.IndentChar = ' ';
doc.WriteContentTo(writer);
editResult.Text = sb.ToString();
相关的文章在这里