XmlWriter.WriteRaw indentation

[亡魂溺海] 提交于 2019-12-08 15:10:27

You could build a valid Xml-Document in memory containing your xml fragment. Then read this document with the XmlReader (e.g. by using MemoryStream) and let the XmlWriter write indented xml.

A faster approach wold be indenting the xml yourself by manipulating the string. Search for <, increase the nesting level and add the indention spaces. If you find </ or a self closing tag decrease the nesting level and append a \n

I don't think there is a fast and nice solution to your problem, but i might be wrong...

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!