Reject angle brackets via System.Xml.XmlWriter

I am writing a string containing XML through System.Xml.XmlWriter. I am stuck using WriteString (), and from the documentation:

WriteString performs the following actions: The characters &, <and> are replaced by &, & lt; and>, respectively.

I would like this to stop, but I cannot find any XmlWriterSettings properties to control this behavior. What are some workarounds? Thank!

David

+3
source share
3 answers

Try wrapping your real content between CDATA tags:

<! [CDATA [ this is my content ]]>

+1
source

WriteString , &, < > XML, .

, , .

XML, WriteRaw.

+1

I am stuck using WriteString (),

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

0
source

Source: https://habr.com/ru/post/1696896/


All Articles