I have some code that allows users to download an xml file to their PCs. I am storing the xml in an XmlDocument and saving that via the Response.Output. Saving the xml in this way seems to be adding on an xml declaration because the xml I am loading doesn't
include one.
Does anyone know how to get rid of the declaraction that is getting added?
None
0 Points
3 Posts
Removing XML Declaration From Download
Jan 04, 2013 03:25 PM|aoloki|LINK
I have some code that allows users to download an xml file to their PCs. I am storing the xml in an XmlDocument and saving that via the Response.Output. Saving the xml in this way seems to be adding on an xml declaration because the xml I am loading doesn't include one.
Does anyone know how to get rid of the declaraction that is getting added?
All-Star
94130 Points
18109 Posts
Re: Removing XML Declaration From Download
Jan 05, 2013 10:35 PM|Decker Dong - MSFT|LINK
Hi,
What result do you fetch after using the codes above?
None
0 Points
3 Posts
Re: Removing XML Declaration From Download
Jan 07, 2013 09:20 AM|aoloki|LINK
I get the XML that I want tagged with the following header.
<?xml version="1.0" encoding="utf-8" ?>
I do not want this header.
All-Star
94130 Points
18109 Posts
Re: Removing XML Declaration From Download
Jan 07, 2013 08:07 PM|Decker Dong - MSFT|LINK
Hello,
1) Please use XDocument.Load to load the xml file or string (to load string, please use Parse).
2) Then re-write to another file with XDocunent's Root property.
None
0 Points
3 Posts
Re: Removing XML Declaration From Download
Jan 08, 2013 04:11 PM|aoloki|LINK
Still not working.
It seems to be something to do with this line
If I make it a ".txt" file instead it will not include the header. Is there a way to default a filename without using that?
All-Star
94130 Points
18109 Posts
Re: Removing XML Declaration From Download
Jan 09, 2013 08:24 PM|Decker Dong - MSFT|LINK
Hi,
No.
I mean that you can just output your xml in the formation of string, and then do saving. Because if in "string" mode, you can remove that headerline.