问题
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