472,980 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,980 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 5656
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.