tags:

views:

475

answers:

3

Hi,

I'm writing a string containing some XML via System.Xml.XmlWriter. I'm stuck using WriteString(), and from the documentation:

WriteString does the following: The characters &, <, and > are replaced with &amp;, &lt;, and &gt;, respectively.

I'd like this to stop, but I can't seem to find any XmlWriterSettings properties to control this behavior. What are some workarounds? Thanks!

David

A: 

I'm stuck using WriteString(),

I think that's the root of your problem. Can you explain more about your reason you're stuck using WriteString? My gut is you're using the wrong method for what you want to do

Danimal
Actually, I'm using the Argotic syndication framework to generate an Atom Feed, and it uses WriteString() internally for writing some elements out.
David Rubin
A: 

Try wrapping your real content between the CDATA tags:

<![CDATA[ it's my content ]]>

Haoest
+1  A: 

WriteString writes your content as a literal, and &, < and > are illegal in XML text, so they are escaped.

If the other end is not unescaping them, that's where the problem lies.

If you want to write unescaped XML, use WriteRaw.

Mike Dimmick