将
XML节点的外部文本放在WPF文本框中是很简单的.但是有没有办法让文本框格式化为XML文档?有不同的控制吗?
这应该是诀窍:
原文链接:https://www.f2er.com/xml/292216.htmlprotected string FormatXml(string xmlString) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlString); StringBuilder sb = new StringBuilder(); System.IO.TextWriter tr = new System.IO.StringWriter(sb); XmlTextWriter wr = new XmlTextWriter(tr); wr.Formatting = Formatting.Indented; doc.Save(wr); wr.Close(); return sb.ToString(); }