473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Problem outputting xml from ASP.Net page

1
I want to output XML from an ASP.Net page and have created the code below:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Data.SqlClient;
  8. using System.Xml;
  9. using System.Text;
  10. using System.Data.OleDb;
  11.  
  12. public partial class Resources_Booking_xmlBookingData : System.Web.UI.Page
  13. {
  14.     public DateTime SelectedDate = System.DateTime.Today;
  15.     public DateTime FirstofWeek = System.DateTime.Today;
  16.     public int ResourceCategory;
  17.  
  18.     protected void Page_Load(object sender, EventArgs e)
  19.     {
  20.         // Create a new XmlTextWriter instance
  21.         XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
  22.  
  23.         Response.Cache.SetCacheability(HttpCacheability.NoCache);
  24.  
  25.         // Start Writing
  26.         writer.WriteStartDocument();
  27.  
  28.         /* MY ACTUAL XML, GENERATED FROM DB QUERIES */
  29.     }
  30. }
But this just outputs a blank browser window, with the following source:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML><HEAD>
  3. <META content="text/html; charset=utf-8" http-equiv=Content-Type></HEAD>
  4. <BODY></BODY></HTML>
Maybe I am missing something obvious, can anyone see what it may be?
Sep 30 '09 #1
1 1278
Frinavale
9,735 Expert Mod 8TB
I'm surprised that you're even seeing that HTML...

Browsers use HTML in order to determine how to display the output.
You can't just send a browser any old XML...it has to be HTML in order to display.

If you are writing XML directly to the output stream then you are sending the browser XML, not HTML.

How is the browser supposed to know what to do with it?

-Frinny
Oct 1 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jonathan | last post by:
I have a client solution that requires data and associated files to be stored with data in a database. As such, I have a situation where JPEG thumbnails/images that are stored as BLOBs (image...
5
by: Andrei Pociu | last post by:
I have a major doubt about outputting text in ASP .NET when using code behind. I know most of the output you gain from a code behind file (.aspx.cs) is outputted to the Webform (.aspx) using...
2
by: prince -=nore=- | last post by:
I have a page, where I'm retrieving a file location from a database and outputting it's contents (HTML) onto a web page. On the aspx page, I have referred to the code behind it using the line...
5
by: Richard | last post by:
I've developed a small ASPX template framework (based on Chun Li's article on CodeProject: http://www.codeproject.com/aspnet/headerfooter.asp#xx849313xx) which uses a IHttpModule to apply...
4
by: Terry | last post by:
I have a form that my wife uses to update her tennis racket website. I modified it to allow data entry, modify, and delete. If you enter an id number you get the matching record if there is one. ...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
17
by: Matt | last post by:
Hello. I'm having a very strange problem that I would like ot check with you guys. Basically whenever I insert the following line into my programme to output the arguments being passed to the...
11
by: =?ISO-8859-1?Q?Jean=2DFran=E7ois_Michaud?= | last post by:
Context: I'm trying to compare XML tree fragments and I'm doing so by outputting the attributes of each element in the tree and outputting it to a string then normalizing the strings. Then I'm...
12
by: billelev | last post by:
This is probably a very easy question to answer: I have been outputting some text to a message box, similar to the following: strOutput = "---" & Chr(10) & Chr(10) strOutput = strOutput &...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.