Hi Stan,
From your description, you're wanting to use the ASP.NET xml Server Control
to display raw xml data in the page's response output rather than use some
certain xsl to transform them into html ,yes?
As this question, I'm afraid such operation is not allowed because each
ASP.NET web page will return as a certain ContentType, such as "text/html",
"text/xml", "image/gif" , "application/ms-excel" ...
By default , an aspx page is rendered as html page and its contenttype is
"text/html". And when we us the Xml Server control on it, we need to
specify a xls file or a XslTransform object to it so as to transform the
giving XmlDocuemnt intoHtml so that the result can be embeded into the
page's output response. If we don't transfer it and want to display raw xml
in the page, that means we want to mix a "text/html" type stream with
"text/xml" data which is apparent not allowed. And that's why the raw xml
data is not displayed. Do you think so?
If you do want to display xml data in page, you have the following means:
1. Change the reponse's ContentType to "text/xml" and then write pure xml
data into the response steam, such as:
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();
2. Or write out the XmlData As normal string text into a certain control
such as "Literal" or "Label" control, we need to html encode it so as to
display correctly. For example:
XmlDocument doc = new XmlDocument();
DataSet ds = GetDataSet();
string xml = ds.GetXml();
lblXml.Text = HttpUtility.HtmlEncode(xml);
#lblXml is a Label control
These are some of my suggestions. Hope helps.
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