471,326 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,326 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 5587
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ghost | last post: by
5 posts views Thread by Gilgamesh | last post: by
2 posts views Thread by fmancina | last post: by
3 posts views Thread by janus1114 | last post: by
6 posts views Thread by clintonG | last post: by

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.