473,805 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem outputting xml from ASP.Net page

1 New Member
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 1303
Frinavale
9,735 Recognized Expert Moderator Expert
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
1824
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 data-type) in a SQL DB need to be written to an ASP.NET page. The BLOB is actually wrapped by a class written in C#, BlobObj, which can return a byte-array containing the image-bytes. I can successfully write the image to the page using the...
5
2821
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 labels, datagrids, datalists... Also, I know you can output directly using Response.Write(). But this places the output at the beginning of the file. How can you output the text at a specific place in the HTML code? An example would be when...
2
1635
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 below. This is where I'm getting the "Object reference not set to an instance.." error <% response.writefile(thelink())%>. The function that line is referring to is below. The record is being retrieved from the database according to its...
5
2192
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 usercontrols (e.g. header and footer) on pages. The module determines if templates should be added to the page using Page.Request.Path. It matches the current adress to settings found in a configuration-file... It works like a charm except for one...
4
2313
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. The data from that record is now displayed in the form ready to change. The second submit of the same id updates the record. $description=$_POST; $grip=$_POST; // Sizes are in inches (") if ($id) {
4
10519
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 doesn't seem to write to the screen in the way I would expect. The output is:
2
3158
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 then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
17
3384
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 programme: printf("\nCommand line arguement %d: %s.", i , argv ); The porgramme outputs 3 of the command line arguements, then gives a segmentation fault on the next line, followed by other strange
11
2096
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 doing a contains of the current string against the following-sibling::* to determine if we have duplicates. If we have a duplicate, we move to the next item, if there is no duplicate, we output the small tree. I'm hitting a completely ridiculous...
12
13432
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 & "VAR:" & AddTabs(1) & Format(rsVar!, "currency") strOutput = strOutput & Chr(10) & Chr(10) strOutput = strOutput & "Position Value:" & AddTabs(1) & Format(rsVar!, "currency") & Chr(10) strOutput = strOutput & "Position Risk:" & AddTabs(1) &...
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10607
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10359
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10104
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7645
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5541
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.