Can I use XDocument.Save and exclude the XML Declaration?

时光怂恿深爱的人放手 提交于 2020-01-23 12:57:33

问题


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?


回答1:


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

Just found this article which seems to agree.



来源:https://stackoverflow.com/questions/711954/can-i-use-xdocument-save-and-exclude-the-xml-declaration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!