Writing formatted XML with XmlWriter

前端 未结 4 1592
臣服心动
臣服心动 2021-01-07 23:31

I\'m trying to write to an XML file to the isolated storage but I would like to format it like this:-


  

        
4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-07 23:54

    If, like me, you're implementing your own XmlWriter you can do:

    var myXmlWriter = new MyXmlWriter(stream, System.Text.Encoding.UTF8)
    {
        Formatting = Formatting.Indented
    };
    

    or do this.Formatting = Formatting.Indented in it's constructor.

提交回复
热议问题