473,405 Members | 2,300 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,405 software developers and data experts.

response.writing out UTF8 XML. How?

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 XmlTextWriter(Response.OutputStream, Encoding.UTF8)

That fixed the issue.

I'm not generating an XML file using a different method grabbing XML from a
DB and then reading it in as a stringreader, then transforming that via an
XSLT file.

Eventually, I do the XSLT transformation and response.write the result to
the browser.

The problem is that, once again, it's being set witn a UTF16 encoding.

I've tried to explicitely set the response encoding as such:

-------------
xslt.Transform(doc, xslArg, sw, Nothing)
Response.ContentType = "text/xml"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.Write(sw.ToString)
Response.End()
-------------

But I STILL get the UTF16 declaration in my XML:

<?xml version="1.0" encoding="utf-16"?><rss version="2.0">...

Why!?

-Darrel
Jul 17 '07 #1
2 8385
darrel wrote:
The problem is that, once again, it's being set witn a UTF16 encoding.

I've tried to explicitely set the response encoding as such:

-------------
xslt.Transform(doc, xslArg, sw, Nothing)
Response.ContentType = "text/xml"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.Write(sw.ToString)
Response.End()
-------------

But I STILL get the UTF16 declaration in my XML:

<?xml version="1.0" encoding="utf-16"?><rss version="2.0">...
Don't transform to a StringWriter, instead transform directly to
Response.Output:
Response.ContentType = "application/xml"
xslt.Transform(doc, xslArg, Response.Output, Nothing)
And make sure your XSLT stylesheet has
<xsl:output method="xml" encoding="UTF-8"/>
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 18 '07 #2
Don't transform to a StringWriter, instead transform directly to
Response.Output:
Aha!

So, I have this now:

Response.ContentType = "text/xml"
Response.ContentEncoding = System.Text.Encoding.UTF8
xslt.Transform(doc, xslArg, Response.Output, Nothing)
Response.End()

And that works! However, I've never epxlicitely put the <?xml...tag in my
XSLT. It seems that this is generated for me via the response output. Should
I be explicitly including this in my XSLT file?

-Darrel
Jul 18 '07 #3

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

Similar topics

5
by: Tammy | last post by:
Hi, I have an aspx app which needs to post data to a form and read the response. I am confused on whether I should be using the get_url using "POST" method or the post_url using "GET" method. ...
3
by: Brad | last post by:
I have a response filter which injects "standard" html into my pages. The filter works fine when the initial stream is small enough not to buffer...or....if I have a large unbuffered stream (i.e. I...
1
by: richardtallent | last post by:
(ASP.NET 2.0. Issue presents both on my copy of IIS on my workstation (XP Pro) and my production server (Win2k3). I don't use any proxy servers, anti-spyware apps, etc. Problem occurs using IE6SP2...
2
by: Craig | last post by:
I have the need to write a byte of information to a specific location in a text file. eg. the file looks something like this. FYYNN Line 1 Line 2 <eof>
0
by: ed | last post by:
Hello All. I have seen many posts slightly similar to this question with no answer. Maybe you have some FAQs or something, sorry if I looks repetitive. Here is my Problem: In my...
4
by: | last post by:
Hi all, I want to create a method that does the following: 1) Programmatically instantiate a new XmlDataSource control 2) For each file in a named directory, make a "FileSystemItem" element 3)...
0
by: shintu | last post by:
Hallo, I am trying to write french accented characters é è ê in Excel worksheet using my perl script , But I am stuck here as I couldnt find a way of writing it !: My code: use strict;...
3
by: Ira.Kovac | last post by:
Hello All, I am trying to fix PHP code developed by somebody else and my knowledge of PHP is very limited so I'd appreciate any help. I have a MySQL database configured to accept UTF-8 in all...
1
by: Mudcat | last post by:
In short what I'm trying to do is read a document using an xml parser and then upload that data back into a database. I've got the code more or less completed using xml.etree.ElementTree for the...
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
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...
0
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
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...
0
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
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...

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.