使用 XmlWriter 编写格式化的 XML [英] Writing formatted XML with XmlWriter

查看:30
本文介绍了使用 XmlWriter 编写格式化的 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 XML 文件写入隔离存储,但我想将其格式化为:-

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

<SampleData>
  <Item Property1="AliquaXX" />
  <Item Property1="Integer" />
  <Item Property1="Quisque" />
  <Item Property1="Aenean" />
  <Item Property1="Mauris" />
  <Item Property1="Vivamus" />
  <Item Property1="Nullam" />
  <Item Property1="Nam" />
  <Item Property1="Sed" />
  <Item Property1="Class" />
</SampleData>

但是如果我能解决的话我很烦,有人可以帮忙吗?

but I'm buggered if I can work it out, can anyone help?

推荐答案

您可以通过 XmlWriterSettings.

您没有包含任何代码,但是您可以在创建 XmlWriter 时设置 XmlWriterSettings.你也可以使用类似的东西:

You didn't include any code, but you can set the XmlWriterSettings when you create the XmlWriter. You can also just use something like:

var myXmlWriter = new XmlWriterSettings { Indent = true };

这篇关于使用 XmlWriter 编写格式化的 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆