Thursday, May 5, 2011

Write xml text on aspx page

you can use below code to write xml file data (string) on page.

first of all remove all content from aspx page except "page" directive.

 XmlDocument doc = new XmlDocument();
 doc.LoadXml(stringxml);
 Response.Clear(); //optional: if we've sent anything before
Response.ContentType = "text/xml"; //must be 'text/xml'
Response.ContentEncoding = System.Text.Encoding.UTF8; //we'd like UTF-8
doc.Save(Response.Output); //save to the text-writer 
Response.End(); 

Share This!


No comments:

Powered By Blogger · Designed By Seo Blogger Templates