473,320 Members | 1,799 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.

XmlTextWriter and WriteElementString

I'm creating XML using the above. My problem is that if I have a string that
is passed to WriteElementString such as
WriteElementString("description", @"<![CDATA[<a
href=""http://www.google.com"">Here is the link</a>]]>");
then, it outputs the XML as...
<description>&lt;![CDATA[&lt;a href="http://www.google.com"&gt;Here is the
link&lt;/a&gt;]]&gt;</description>

I don't want it to convert the < to &lt; etc. Is there a way to make
XmlTextWriter not convert the characters? Or should I go another route?

Thanks
Jul 17 '08 #1
2 5668
Randy <te**@temp.comwrote:
I'm creating XML using the above. My problem is that if I have a string that
is passed to WriteElementString such as
WriteElementString("description", @"<![CDATA[<a
href=""http://www.google.com"">Here is the link</a>]]>");
then, it outputs the XML as...
<description>&lt;![CDATA[&lt;a href="http://www.google.com"&gt;Here is the
link&lt;/a&gt;]]&gt;</description>

I don't want it to convert the < to &lt; etc. Is there a way to make
XmlTextWriter not convert the characters? Or should I go another route?
If you want to write the raw characters, use WriteRaw.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon_skeet
C# in Depth: http://csharpindepth.com
Jul 17 '08 #2
That did it!...Thanks!

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP********************@msnews.microsoft.com.. .
Randy <te**@temp.comwrote:
>I'm creating XML using the above. My problem is that if I have a string
that
is passed to WriteElementString such as
WriteElementString("description", @"<![CDATA[<a
href=""http://www.google.com"">Here is the link</a>]]>");
then, it outputs the XML as...
<description>&lt;![CDATA[&lt;a href="http://www.google.com"&gt;Here is
the
link&lt;/a&gt;]]&gt;</description>

I don't want it to convert the < to &lt; etc. Is there a way to make
XmlTextWriter not convert the characters? Or should I go another route?

If you want to write the raw characters, use WriteRaw.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon_skeet
C# in Depth: http://csharpindepth.com

Jul 17 '08 #3

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

Similar topics

5
by: reddy | last post by:
I am trying to insert a node into an XMLFile. using XMLTextwriter. My Question is Is it possible to do without using XMLDocument. Because its loading all the the file into memory. I just want to...
3
by: Dave | last post by:
Hi, I'm trying to create an XML document with XMLTextWriter but I want to store it in memory (not write it to a file like so many examples do). I tried the following but with no luck. Should I not...
1
by: SQLScott | last post by:
I have the following code that is supposed to use the XMLTextWriter to write the XML to a MemoryStream: Dim ms As MemoryStream ms = New MemoryStream Dim xtw As New Xml.XmlTextWriter(ms,...
2
by: Ghost | last post by:
Can anybody how do I use XmlTextWriter example? I want to write such XML file: <?xml version="1.0" standalone="yes"?> <Clients> <Client> <Name>David</Name> <Age>27</Age> </Client>
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...
5
by: Gilgamesh | last post by:
Hello, How do I use this class to create an XML document without saving it into a file? I need to store the XML documen into a string so it could be passed as a parameter to another class....
2
by: fmancina | last post by:
Hi, I am employing the XmlTextWriter class to generate an XML document. Everything works fine, until I have to write an attribute to an element which contains a value. Examples below: //...
3
by: janus1114 | last post by:
Hello, I'm using XMLTextWriter to create a XML file from a database table. I use WriteElementString to create elements. I'm having two issues: 1. When a data field is null, I get an error. ...
6
by: clintonG | last post by:
Can anybody make sense of this crazy and inconsistent results? // IE7 Feed Reading View disabled displays this raw XML <?xml version="1.0" encoding="utf-8" ?> <!-- AT&T HTML entities & XML...
1
by: mrdanny2007 | last post by:
Is there anyway to get the XML string representation from the XmlTextWriter object? I created a function to create an XML using this object, but I need to send back an XML as the return value of...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: 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)...
0
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: 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....

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.