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

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 3137
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Adam Rothberg | last post by:
The following code sample should produce a valid xml file to the console. However, when I try this in C# (Visual Studio 2003, 1.1 Framework), there is an extra questionmark preceding the rest of...
5
by: Jain, Pranay Kumar | last post by:
Hello Everyone, I have written a simple app. that converts the dataset into excelspreadsheet. The App. uses the following architecture. First it generates the dataset with corresponding...
3
by: Magnus | last post by:
can anyone help me on how to create and manipulate a xmttextwriter without having to craete a physical file. I have an application that should return data in xml. But I do not want to create a...
4
by: H Lee | last post by:
Hi, I'm an XML newbie, and not sure if this is the appropriate newsgroup to post my question, so feel free to suggest other newgroups where I should post this message if this is the case. I'm...
3
by: K Rege | last post by:
Hi there, I tried to implement a little XML-EchoServer using Sockets and XmlTextWriter/Reader. However the server hangs while reading the input from the client (wr.Flush() seams not to work). I...
2
by: Josh Newman | last post by:
I'm using the XMLTextWriter to create an XML document. I do not want the encoding attribure in the XML file. Instead of: <?xml version="1.0" encoding="utf-8"?> I want: <?xml version="1.0"?>...
5
by: Robert Dickow | last post by:
Hi, My XML files created with XmlTextWriter routines has been resulting in working files, but they include three bytes of garbage at the start of the file. The bytes are: $EF $BB $BF (I think...
2
by: Mori | last post by:
I am using the following code to manufactue xml using xmltextwriter. The xml is okay except for the extra set of start document and the outer <string> element. Where do they come from and how do...
1
by: hharry | last post by:
hi all i have the following class: <Serializable()> _ Public Class MVR_Inputs Public FirstName As String Public MiddleName As String Public LastName As String Public Suffix As String
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.