I want to output XML from an ASP.Net page and have created the code below:
- using System;
-
using System.Data;
-
using System.Configuration;
-
using System.Collections.Generic;
-
using System.Linq;
-
using System.Web;
-
using System.Data.SqlClient;
-
using System.Xml;
-
using System.Text;
-
using System.Data.OleDb;
-
-
public partial class Resources_Booking_xmlBookingData : System.Web.UI.Page
-
{
-
public DateTime SelectedDate = System.DateTime.Today;
-
public DateTime FirstofWeek = System.DateTime.Today;
-
public int ResourceCategory;
-
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
// Create a new XmlTextWriter instance
-
XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
-
-
Response.Cache.SetCacheability(HttpCacheability.NoCache);
-
-
// Start Writing
-
writer.WriteStartDocument();
-
-
/* MY ACTUAL XML, GENERATED FROM DB QUERIES */
-
}
-
}
But this just outputs a blank browser window, with the following source:
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
<HTML><HEAD>
-
<META content="text/html; charset=utf-8" http-equiv=Content-Type></HEAD>
-
<BODY></BODY></HTML>
Maybe I am missing something obvious, can anyone see what it may be?