Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How properly return XML from an ASPX page?

Reply
Thread Tools

How properly return XML from an ASPX page?

 
 
Ronald S. Cook
Guest
Posts: n/a
 
      03-18-2006
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




 
Reply With Quote
 
 
 
 
Karl Seguin [MVP]
Guest
Posts: n/a
 
      03-18-2006
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" <> wrote in message
news:...
>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
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return an XML string from aspx page webnet ASP .Net 0 11-19-2007 01:07 PM
asp.net 2.0 - aspx file to return xml? Sergei Shelukhin ASP .Net 4 06-19-2006 03:24 AM
adding main.aspx.vb & main.aspx.resx under aspx John M ASP .Net 1 05-29-2005 09:27 PM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
More American Graffiti: Properly Framed, Properly Scored? Scot Gardner DVD Video 0 09-02-2003 02:28 AM



Advertisments