outerxml

What is the simplest way to get indented XML with line breaks from XmlDocument?

廉价感情. 提交于 2019-11-26 12:05:57
When I build XML up from scratch with XmlDocument , the OuterXml property already has everything nicely indented with line breaks. However, if I call LoadXml on some very "compressed" XML (no line breaks or indention) then the output of OuterXml stays that way. So ... What is the simplest way to get beautified XML output from an instance of XmlDocument ? Neil C. Obremski Based on the other answers, I looked into XmlTextWriter and came up with the following helper method: static public string Beautify(this XmlDocument doc) { StringBuilder sb = new StringBuilder(); XmlWriterSettings settings =

What is the simplest way to get indented XML with line breaks from XmlDocument?

荒凉一梦 提交于 2019-11-26 02:50:39
问题 When I build XML up from scratch with XmlDocument , the OuterXml property already has everything nicely indented with line breaks. However, if I call LoadXml on some very \"compressed\" XML (no line breaks or indention) then the output of OuterXml stays that way. So ... What is the simplest way to get beautified XML output from an instance of XmlDocument ? 回答1: Based on the other answers, I looked into XmlTextWriter and came up with the following helper method: static public string Beautify