473,322 Members | 1,504 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,322 software developers and data experts.

How to use response output with a stringwriter?

I'm creating an RSS feed based off of this tutorial:

http://www.uberasp.net/ArticlePrint.aspx?id=17

In a nutshell, they are doing:

Response.Clear()
Response.ContentType = "text/xml"
....use xmltextwriter to create xml...
response.end()
I want to do the same, but instead of using an xmltextwriter, I'm using XSLT
to create the XML file. I'm stumped on how dto do this. I currently have:

Response.Clear()
Response.ContentType = "text/xml"
....set up xslt...
Dim sw As New StringWriter
xslt.Transform(doc, xslArg, sw, Nothing)
sw.Write(sw.ToString) // <-- where I'm stumped
response.end()

That doesn't work. How do I get a Stringwriter to output it's content into
the response?

-Darrel
Mar 27 '07 #1
3 4133
Since you are transforming, you probably have an HTML page (not necessarily
as you can make XML + XSLT = XML or XML + XSLT = text). If you do have an
HTML page, get rid of the text/xml. You will have to go to a stream, not a
streamwriter.

The final chapters of ADO.NET and XML: ASP.NET on the edge show a 1.0
transform to a stream (it is different in 2.0). You can download from
http://www.wiley.com/extras. This will at least have you understand writing
to a stream. Unfortunately, I do not have a 2.0 code sample, but it should
be fairly similar, although the transform class has changed. Short story:
The downloaded code WILL blow up in 2.0, but it is useful for understanding
the idea.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*********************************************
Think outside the box!
*********************************************
"darrel" <no*****@nowhere.comwrote in message
news:Og**************@TK2MSFTNGP05.phx.gbl...
I'm creating an RSS feed based off of this tutorial:

http://www.uberasp.net/ArticlePrint.aspx?id=17

In a nutshell, they are doing:

Response.Clear()
Response.ContentType = "text/xml"
...use xmltextwriter to create xml...
response.end()
I want to do the same, but instead of using an xmltextwriter, I'm using
XSLT to create the XML file. I'm stumped on how dto do this. I currently
have:

Response.Clear()
Response.ContentType = "text/xml"
...set up xslt...
Dim sw As New StringWriter
xslt.Transform(doc, xslArg, sw, Nothing)
sw.Write(sw.ToString) // <-- where I'm stumped
response.end()

That doesn't work. How do I get a Stringwriter to output it's content
into the response?

-Darrel
Mar 27 '07 #2
That doesn't work. How do I get a Stringwriter to output it's content
into the response?
Ok, this has to be one of the biggest brainfarts I ever had.

response.write(sw.tostring)

duh! ;o)

-Darrel
Mar 27 '07 #3
I find those right after I hit send. :-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*********************************************
Think outside the box!
*********************************************
"darrel" <no*****@nowhere.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
>That doesn't work. How do I get a Stringwriter to output it's content
into the response?

Ok, this has to be one of the biggest brainfarts I ever had.

response.write(sw.tostring)

duh! ;o)

-Darrel
Mar 27 '07 #4

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

Similar topics

2
by: John Meyer | last post by:
I have an application where I create an xml fragment using an XslTransform object. However, if I use the following output method, <xsl:output method="xml" version="1.0" encoding="UTF-8"...
3
by: Joseph A Romeo | last post by:
I have written an XSLT transformation on an ASP.NET page. The resulting HTML is primarily a table of links. I have found that when the resulting HTML is less than or equal to 16040 bytes, the...
2
by: Buddy Ackerman | last post by:
Apparently .NET strips these white space characters (MSXML doesn't) regardless of what the output method is set to. I'm using <xsl:text> </xsl:text> to output a tab character and...
2
by: Joseph | last post by:
Hello. I have this problem. See I have a transformed XML file and I checked its contents prior to outputting it to excel file via responseset. here is the gist of the code: XmlReader reader =...
1
by: Tom Vergote | last post by:
Hello world, I'm running into an issue where I would like to save the response stream as an html file on the server (and convert it to a pdf) I've tried putting a streamreader on the...
1
by: claudia villatoro via .NET 247 | last post by:
Hi I have a page with an option for opening the result( dataset) inexcel and it works, but the excel's file opens in the currentpage, I'd like to open it in a new page, How could I do ? ( Ithink I...
5
by: Tim_Mac | last post by:
hi, i read that by adding the following code to by aspx pages, it would not store temporary internet files: Response.Cache.SetCacheability(HttpCacheability.NoCache); it didn't actually work...
2
by: darrel | last post by:
I was having issues before with my XML being sent to the browser as UTF16. Via my XmlTextWriter, was able to fix this by explicitely setting the encoding to UTF8: Dim objX As New...
3
by: kellygreer1 | last post by:
PHP will alllow you to build up an entire page and before sending that out as the response.... you can grab all the text and do search and replaces, add comments, make more CSS/XHTML compliant,...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.