Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Character Escape When Calling XmlWriter.WriteElementString

Tags:

c#

.net

xml

I have a string:

<entry key="Provider">Comcast Cable Communications, Inc.</entry>
<entry key="Challenged">No</entry>

I want to output this string using XmlWriter.WriteElementString(). The problem here is that XmlWriter.WriteElementString() will escape all < and > characters with &lt; and &gt;. I have checked MSDN to see if there is a way to disable that from happening but have not found an answer.

Is there a way to disable the auto-escaping that is occuring?

like image 442
Ibrar Afzal Avatar asked Apr 28 '26 09:04

Ibrar Afzal


1 Answers

Using the XmlWriter.WriteRaw() method to output the text resolved my problem.

like image 97
Ibrar Afzal Avatar answered Apr 29 '26 22:04

Ibrar Afzal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!