我可以使用XDocument.Save和排除XML声明? [英] Can I use XDocument.Save and exclude the XML Declaration?

查看:307
本文介绍了我可以使用XDocument.Save和排除XML声明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加载XML文件到一个的XDocument,做的东西给它,并调用保存(文件名)重写XML文件。原始文件没有XML声明,反正是有避免的XDocument添加XML声明?

I'm loading a XML file into a XDocument, doing stuff to it, and calling Save(fileName) to rewrite the XML file. The original file has no XML declaration, is there anyway to avoid XDocument adding a XML declaration?

推荐答案

我认为你必须使用的XmlWriter。或者的ToString。

I think you'll have to use an XmlWriter. Or ToString.

刚刚发现这篇文章这似乎是同意的。

Just found this article which seems to agree.

这篇关于我可以使用XDocument.Save和排除XML声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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