here the c# code I use to respond xml data
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
public partial class xmlData : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "text/xml";
String xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"+
"<note>"+
"<to>Tove</to>"+
"<from>Jani</from>"+
"<heading>Reminder</heading>"+
"<body>Don't forget me this weekend!</body>"+
"</note>";
Response.Write(xml);
}
}
but I got this error .. why ?
This page contains the following errors:
error on line 3 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.
You need to call
Response.Endto stop the rest of the page from being rendered after your XML – or preferrably, don’t have this as a “page” in the first place. It’s not really a page, after all – it’s just some XML. It sounds like you really want a “handler” (ASHX file and a class implementingIHttpHandler) instead, which isn’t going to automatically add any content for you.