Writing formatted XML with XmlWriter

前端 未结 4 1578
臣服心动
臣服心动 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-08 00:14

    I suspect you need to create an XmlWriterSettings with the behaviour you want (indentation etc) and then pass that to the XmlWriter on creation. Just setting Indent to true may well be enough:

    XmlWriterSettings settings = new XmlWriterSettings { Indent = true };
    using (XmlWriter writer = XmlWriter.Create(..., settings))
    {
        ...
    }
    

提交回复
热议问题