Cindy wrote:
I use XmlSerializer to serialize xml string. It escapes xml special
charaters, like < and > to < and >. How can I stop XmlSerializer to escape
these charaters?
If the XmlSerializer didn't escape the characters < and & (and for
compatibility >), then the result would not be well-formed XML. See section
2.4 of the XML specification [1]. Here's a portion of the spec:
"The ampersand character (&) and the left angle bracket (<) MUST NOT appear
in their literal form, except when used as markup delimiters, or within a
comment, a processing instruction, or a CDATA section. If they are needed
elsewhere, they MUST be escaped using either numeric character references or
the strings "&" and "<" respectively. ..."
Is there a reason you don't want to generate well-formed XML, or are you
trying to use the XmlSerializer to generate CDATA sections?
Cheers,
Stuart Celarier, Fern Creek
[1]
http://www.w3.org/TR/2004/REC-xml-20040204/#syntax