XmlTextWriter and WriteElementString

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

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
 
Randy said:
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.
 
That did it!...Thanks!

Jon Skeet said:
Randy said:
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 - <[email protected]>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon_skeet
C# in Depth: http://csharpindepth.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top