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?
Keyword explicit tells compiler to not use the constructor for implicit conversion. For example declaring Bar's constructor explicit as - explicit Bar(int i); - would prevent us from calling ProcessBar as - ProcessBar(10); .
There are two types of conversion: implicit and explicit.
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");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With