469,954 Members | 1,843 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,954 developers. It's quick & easy.

XmlTextWriter Encoding and Serialization

Two questions:
I've a XmlTextWriter that I want to use to build a string in memory.
However, when I'm using a StringWriter, the xml comes out at UTF-16, which
isn't good for me.
Currently, I solved the problem by using XmlDocument, but it seems a waste
to use that if I can use XmlWriter.
I tried to spesify the encoding, and then it complained about needing a
Stream and not a TextWriter.
I *must* have this in memory, writing to file is not an option in this case.
I tried using MemoryStream, but I can't seem to get the Xml out.
How do I do this?

Second question:
I've a type that was built from xsd schema, when I try to serialize it I get
an error (need to add XmlInclude), why?
The first two lines where added by xsd.exe, the third I added, but I still
get this error, why? And how to solve it?
I thought that if I define my type as xsd schema I wouldn't have a problem
serializing it, which was the whole point in doing this.
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://tempuri.org/Rss
Feed.xsd")]

[System.Xml.Serialization.XmlRootAttribute(Namespac e="http://tempuri.org/Rss
Feed.xsd", IsNullable=false)]
[System.Xml.Serialization.XmlInclude(typeof(Feed))]
Nov 12 '05 #1
1 3014
"Ayende Rahien" <Ay****@no.spam> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
Two questions:
I've a XmlTextWriter that I want to use to build a string in memory.
However, when I'm using a StringWriter, the xml comes out at UTF-16, which
isn't good for me.
Currently, I solved the problem by using XmlDocument, but it seems a waste
to use that if I can use XmlWriter.
I tried to spesify the encoding, and then it complained about needing a
Stream and not a TextWriter.
I *must* have this in memory, writing to file is not an option in this case. I tried using MemoryStream, but I can't seem to get the Xml out.
How do I do this?


An interesting discussion of this can be found here:
http://weblogs.asp.net/rmclaws/posts/22080.aspx#24141

--
Bryant
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Adam Rothberg | last post: by
5 posts views Thread by Jain, Pranay Kumar | last post: by
3 posts views Thread by Magnus | last post: by
3 posts views Thread by K Rege | last post: by
2 posts views Thread by Josh Newman | last post: by
5 posts views Thread by Robert Dickow | last post: by
1 post views Thread by hharry | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.