473,511 Members | 16,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How properly return XML from an ASPX page?

I have an ASPX page that returns XML to the calling client. While the code
below works, I don't think it's proper because it's not encoded as XML.
I.e. special characters might screw things up.

Can anyone please tell me the more proper way to do this?

<%@ Page Language="C#" %>

<html>

<body>

<%

Response.Write("<?xml version='1.0'?>");

Response.Write("<Westin><Event><Name>RECEPTION</Name><Floor>2nd
Floor</Floor><StartTime>8:00 AM</StartTime><EndTime>10:00
AM</EndTime></Event></Westin>");

%>

</body>

</html>

Thanks,

Ron


Mar 18 '06 #1
1 3564
Well, you should probably remove the <html> and <body> and ideally hook
into the onLoad event.. your page should be empty

void override onLoad(...)
{
Response.Clear();
Response.ContentType = "text/xml";
Response.Write(UR XML HERE)
Response.End();
}
karl

--
http://www.openmymind.net/

"Ronald S. Cook" <rc***@westinis.com> wrote in message
news:uR**************@TK2MSFTNGP14.phx.gbl...
I have an ASPX page that returns XML to the calling client. While the code
below works, I don't think it's proper because it's not encoded as XML.
I.e. special characters might screw things up.

Can anyone please tell me the more proper way to do this?

<%@ Page Language="C#" %>

<html>

<body>

<%

Response.Write("<?xml version='1.0'?>");

Response.Write("<Westin><Event><Name>RECEPTION</Name><Floor>2nd
Floor</Floor><StartTime>8:00 AM</StartTime><EndTime>10:00
AM</EndTime></Event></Westin>");

%>

</body>

</html>

Thanks,

Ron

Mar 18 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1963
by: Will Waggoner | last post by:
Ok, I've been hung up on this issue for quite some time now and I would like some help in getting it to work. I think this may be a setup issue but I'd like to ask your eminences first. Here's...
1
3294
by: Roberto Castro | last post by:
I have some problems with the way I am showing the BLOB fields in the Image web controls. It does work on my localhost though sometimes I need to hit Refresh for the images to load properly....
1
4282
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
5
2775
by: Nita Raju | last post by:
Hi, I have to validate a textbox for date without using the validation controls. So i had to use IsDate(). It's not working properly when i give "11//2004". When i enter the above date it...
7
2093
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the...
6
2244
by: Ronald S. Cook | last post by:
I have an ASPX page that returns XML to the calling client. While the code below works, I don't think it's proper because it's not encoded as XML. I.e. special characters might screw things up. ...
3
1022
by: Darrel | last post by:
I asked this a while ago but got sidetracked and now have finally gotten back to it. Karl wrote a nice (and easy to read) article here: ...
1
3557
by: Darrel | last post by:
APologies for the cross post...posted in the wrong forum the first time. I have an ASPX page on my server that isn't properly running as an ASPX page. At first, the RESX file would load. I delete...
4
3234
by: Charleees | last post by:
GIFS not working properly in JavaScript PopUps Hi all, I have a button and when i click tha button it redirects to another page..... I have also added a java script for the button that...
8
4729
by: Harvey Schmidlapp | last post by:
I have a fairly complex form (generated by means of an ASP 3 page). The form is used to define a query against a database. After running a query, the user hits their browser's back button and goes...
0
7138
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
7353
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,...
0
7418
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...
1
7075
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
5662
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
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3222
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...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
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 ...

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.