I'm using the following code to create an Xml document to be saved by the
browser (IE):
MemoryStream stream = new MemoryStream();
OrderManager.ExportToXml(stream); // Creates Xml
by using XmlTextWriter to the stream
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment;
filename=BaldrianOrdersMamut.xml");
Response.BinaryWrite(stream.GetBuffer());
Response.End();
This is a sample of the saved Xml file:
<?xml version="1.0" encoding="utf-8"?>
<GBAOX10>
<ORDERLIST />
</GBAOX10>
The problem is that the resulting file that is saved doesn't seem 100%
right. When you read the content in Notepad it looks OK, but IE have a
problem displaying and show an error like this:
"The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
Invalid at the top level of the document. Error processing resource
'file:///C:/Documents and Settings/olavt.SAFARI/My Docu...
</GBAOX10>"
If I just do a File->Save in Notepad overwriting the original file, the
problem disappears.
How can I get the file to save correctly in the first place?
Olav