473,387 Members | 3,801 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,387 software developers and data experts.

Response.Write() rss xml

When writing rss xml to the client browser , is there any reason to load the
rss xml string into an XmlDocument and then Response.Write() the
XmlDocument.OuterXML.ToString() ?

option 1:

string rssXml = null;
-- build rssXML --
Response.Write(rssXml);

option 2:
string rssXml = null;
-- build rssXML --
XmlDocument xmlDoc = new XmlDocument;
xmlDoc.Load(rssXml);
Response.Write(xmlDoc.OuterXml.ToString());
May 4 '06 #1
3 7670


John A Grandy wrote:
When writing rss xml to the client browser , is there any reason to load the
rss xml string into an XmlDocument and then Response.Write() the
XmlDocument.OuterXML.ToString() ?

option 1:

string rssXml = null;
-- build rssXML --
Response.Write(rssXml);

option 2:
string rssXml = null;
-- build rssXML --
XmlDocument xmlDoc = new XmlDocument;
xmlDoc.Load(rssXml);
Response.Write(xmlDoc.OuterXml.ToString());

Why would you want to load into XmlDocument first to then Response.Write
the OuterXml?
I think what you want to do is use an XmlTextWriter to create and write
the XML to the HTTP response e.g.

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server">
void Page_Load () {
Response.ContentType = "application/xml";
XmlTextWriter xmlWriter = new XmlTextWriter(Response.Output);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("gods");
xmlWriter.WriteElementString("god", "Kibo");
xmlWriter.WriteElementString("god", "Xibo");
xmlWriter.WriteEndDocument();
xmlWriter.Close();
}
</script>

Don't build the RSS/XML as a text string, instead make use of
XmlTextWriter which takes care of escaping characters and other
well-formedness constraints.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 5 '06 #2
Re:

Response.ContentType = "application/xml";
XmlTextWriter xmlWriter = new XmlTextWriter(Response.Output);
xmlWriter.Close();

How do you send the XMLTextWriter contents to the client browser ( assuming
you only want to send xml to the client browser ) ?

Don't you have to call XMLTextWriter.Flush() before you cal
XMLTextWriter.Close() ?

Or does the Page.Render() event handler still need to be overriden ?
Something like Response.Write(XMLTextWriter.{some method} )

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:uh*************@TK2MSFTNGP02.phx.gbl...


John A Grandy wrote:
When writing rss xml to the client browser , is there any reason to load
the rss xml string into an XmlDocument and then Response.Write() the
XmlDocument.OuterXML.ToString() ?

option 1:

string rssXml = null;
-- build rssXML --
Response.Write(rssXml);

option 2:
string rssXml = null;
-- build rssXML --
XmlDocument xmlDoc = new XmlDocument;
xmlDoc.Load(rssXml);
Response.Write(xmlDoc.OuterXml.ToString());

Why would you want to load into XmlDocument first to then Response.Write
the OuterXml?
I think what you want to do is use an XmlTextWriter to create and write
the XML to the HTTP response e.g.

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server">
void Page_Load () {
Response.ContentType = "application/xml";
XmlTextWriter xmlWriter = new XmlTextWriter(Response.Output);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("gods");
xmlWriter.WriteElementString("god", "Kibo");
xmlWriter.WriteElementString("god", "Xibo");
xmlWriter.WriteEndDocument();
xmlWriter.Close();
}
</script>

Don't build the RSS/XML as a text string, instead make use of
XmlTextWriter which takes care of escaping characters and other
well-formedness constraints.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

May 5 '06 #3


John A Grandy wrote:

Response.ContentType = "application/xml";
XmlTextWriter xmlWriter = new XmlTextWriter(Response.Output);
xmlWriter.Close();

How do you send the XMLTextWriter contents to the client browser


By creating the XmlTextWriter over Response.Output
new XmlTextWriter(Response.Output)


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 6 '06 #4

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

Similar topics

9
by: Ricardo | last post by:
Hi. How should I pass a " (doble-quote) character to response.write() in order for it to be sent to the output ? Thanks in advance for the help.
0
by: Copa | last post by:
Hello, I am testing buffering an asp page and Flushing information out to the browser, hence i wrote the code in an asp page that follows this Message Post. The loops are suppose to simulate...
2
by: Rob McLennan - ZETLAND | last post by:
Hi, I'm relatively clueless when it comes to correct ASP syntax. I'm testing out a search form for my company's website which is done in ASP. The results are displayed as per the code shown at the...
3
by: Gary | last post by:
I am having a strange problem that I cannot solve. I have an asp page that I use for a user to login and gain access to other pages. When the user logs in I set a couple of session variables like...
9
by: Dominic Godin | last post by:
Hi, I have an asp page that does a lot of processing and reports it's finished by printing the word "Success". For example: <% SomeFunction(SomeVar) SomeFunction(SomeVar1) ...
13
by: TinyTim | last post by:
I'm a newbie at ASP & HTML. It seems that when you use server side code and you're going to return a customized HTML form with several fields and labels, you have to do an extensive amount of...
5
by: Luiz Vianna | last post by:
Guys, I need to send some info to my client while I'm processing some stuff. The flow will be something like : -process -response -process -response .... I imagine to use response.flush...
0
by: jose.mendez22 | last post by:
I'm trying to fire a pop-up window before I execute a lengthy stored procedure so I may utilize this window as a status window on number of records executed. After my response.write statements...
6
by: john | last post by:
The standard method to transmit a file from an aspx page to a browser is to stream the file to the response then end the response. The HTML code generated by the aspx page is discarded, and the...
4
by: cbtechlists | last post by:
I have an ASP app that we've moved from a Windows 2000 to a Windows 2003 server (sql server 2000 to sql server 2005). The job runs fine on the old servers. Part of the app takes a recordset and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...

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.