The '&' in the text gets escaped and gets converted to &
when creating the xml file using XmlTextWriter
but i dont want the conversion to take place how to prevent it?
Is there any other way besides using WriteRaw func of xmltextwriter?
The '&' in the text gets escaped and gets converted to &
when creating the xml file using XmlTextWriter
but i dont want the conversion to take place how to prevent it?
Is there any other way besides using WriteRaw func of xmltextwriter?
Why don't you want this to happen ? It looks to me like the library is enforcing correct character escaping as required by XML.
If you put an unescaped ampersand in XML it is no longer valid XML.
Your two choices are either escape it (which your library is doing):
<tag>One & another</tag>
Or wrap it in CDATA:
<tag><![CDATA[One & another]]></tag>
which can be done by:
xmlWriter.WriteCData("One & another");
I am not sure if it will work, but you might want to check into the XmlWriterSettings Properties available through xmltextwriter.Settings, especially the CheckCharacters property.
On the other hand, as Brian Agnew mentioned, not encoding the & to & might be the wrong way to go as it will invalidate your XML (unless you already encoded it to & in which case you might just want to decode it before giving it to the xmltextwriter class.