Indentation and new line command for XMLwriter in C#

前端 未结 6 796
-上瘾入骨i
-上瘾入骨i 2020-12-09 08:10

I am writing some data to XML file...but when I open it all the values are in a single line...how can write it in readable format?ie each node in new line and indentation?

6条回答
  •  春和景丽
    2020-12-09 08:29

    Set the Formatting Property of the XmlTextWriter:

    TextWriter textWriter;
    var xmlTextWriter = new XmlTextWriter(textWriter);
    xmlTextWriter.Formatting = Formatting.Indented;
    

提交回复
热议问题