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

encoding xml when you don't want it to go to a file

Hi,

I'm trying to create a chunk of XML where I want all the entities to be
encoded properly. However, I don't really want to use XmlTextWriter
because I don't want to XML to go into a file on disk.

Is there a simple utility method which will atke a string and an
encoding and encode it as XML properly such that it could then be
included in a CDATA section in an XML document?

Is it possible to use the XmlWriter base class and redirect output to a
string variable? Or would creating an XML DOM object in emmory be the
best way to go?

Thanks

Simon

Oct 11 '06 #1
2 1671
Simon Kittle wrote:
I'm trying to create a chunk of XML where I want all the entities to be
encoded properly. However, I don't really want to use XmlTextWriter
because I don't want to XML to go into a file on disk.

Is there a simple utility method which will atke a string and an
encoding and encode it as XML properly such that it could then be
included in a CDATA section in an XML document?

Is it possible to use the XmlWriter base class and redirect output to a
string variable?
Sure.

StringWriter sw = new StringWriter();
XmlWriter w = XmlWriter.Create(sw);
....
w.Close();
string xml = sw.ToString();
--
Oleg Tkachenko [XML MVP, MCPD]
http://blog.tkachenko.com | http://www.XmlLab.Net | http://www.XLinq.Net
Oct 11 '06 #2
sweet,

cheers man

Oleg Tkachenko [MVP] wrote:
Simon Kittle wrote:
I'm trying to create a chunk of XML where I want all the entities to be
encoded properly. However, I don't really want to use XmlTextWriter
because I don't want to XML to go into a file on disk.

Is there a simple utility method which will atke a string and an
encoding and encode it as XML properly such that it could then be
included in a CDATA section in an XML document?

Is it possible to use the XmlWriter base class and redirect output to a
string variable?

Sure.

StringWriter sw = new StringWriter();
XmlWriter w = XmlWriter.Create(sw);
...
w.Close();
string xml = sw.ToString();
--
Oleg Tkachenko [XML MVP, MCPD]
http://blog.tkachenko.com | http://www.XmlLab.Net | http://www.XLinq.Net
Oct 11 '06 #3

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

Similar topics

14
by: Sebastian Meyer | last post by:
Hi newsgroup, i am trying to replace german special characters in strings like str = re.sub('ö', 'oe', str) When i work with this, i always get the message UniCode Error: ASCII decoding error...
10
by: Christopher H. Laco | last post by:
Long story longer. I need to get web user input into a backend system that a) only grocks single byte encoding, b) expectes the data transer to be 1 bytes = 1 character, and c) uses the HP Roman-6...
2
by: gnv | last post by:
Hi all, I am writing a cross-browser(i.e. 6 and netscape 7.1) javascript program to save an XML file to local file system. I have an xml string like below: var xmlStr = "<?xml version="1.0"...
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...
6
by: jmgonet | last post by:
Hello everybody, I'm having troubles loading a Xml string encoded in UTF-8. If I try this code: ------------------------------ XmlDocument doc=new XmlDocument(); String s="<?xml...
2
by: jmhmaine | last post by:
During the course of development cycle I receive HTML files from designers that use Macs and PCs, but use tools other then Visual Studio. So these files sometimes are not UTF-8 Encoded. I see...
4
by: Nick | last post by:
Hi, I am trying to output a string of chinese characters as a text file. When I open a file for writing from VB, the file is automatically set to UTF-8 encoding (can tell by opening the file...
6
by: kath | last post by:
Hi all, Platform: winxp Version: Python 2.3 I have a task of reading files in a folder and creating an one excel file with sheets, one sheet per file, with sheet named...
23
by: Allan Ebdrup | last post by:
I hava an ajax web application where i hvae problems with UTF-8 encoding oc chineese chars. My Ajax webapplication runs in a HTML page that is UTF-8 Encoded. I copy and paste some chineese chars...
3
by: LiMBi | last post by:
Hi, Is there a way to encode "??????????? ??????????" to "¶ÒÁ¹Ô´¹Ö§¤Ð µÃ§·Õèà»ç¹" and vice versa. Thanks
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
1
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: 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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.