Hi Tom,
As for the your question that how to add a "<?xml version="1.0" ?>"
declaraion before the dataset's output xml, I think you can try the
following means:
1. Directly using the REsponse.Write to write the "<?xml version="1.0" ?>"
out before write the dataset string. For example:
ds.EnforceConstraints = False
Response.ContentType = "text/xml"
Response.Write("<?xml version="1.0" ?>");
ds.WriteXml(Response.OutputStream, XmlWriteMode.IgnoreSchema)
2. Use a XmlDocument to load the DataSet's Xml first and add a "<?xml
version="1.0" ?>" declaraion via the "XmlDeclaration" class. Then output
the XmlDocument into the Response.OutputStream. This is a formal way, for
example:
private void Page_Load(object sender, System.EventArgs e)
{
XmlDocument doc = new XmlDocument();
DataSet ds = GetDataSet();
doc.LoadXml(ds.GetXml());
XmlDeclaration xmldecl;
xmldecl = doc.CreateXmlDeclaration("1.0","UTF-8",null);
//Add the new node to the document.
XmlElement root = doc.DocumentElement;
doc.InsertBefore(xmldecl, root);
//clear the response's original content
Response.Clear();
Response.ClearContent();
Response.ContentType="text/xml";
doc.Save(Response.OutputStream);
Response.End();
}
In addition, here are some reference on using XMLDocument in MSDN:
#XmlDocument Class
http://msdn.microsoft.com/library/en...XmlXmlDocument
ClassTopic.asp?frame=true
#XmlDocument.CreateXmlDeclaration Method
http://msdn.microsoft.com/library/en...xmlxmldocument
classcreatexmldeclarationtopic.asp?frame=true
Hope also helps. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx