XmlSerializer and Mark-up (Xml or Html)
Posted
by Kieron
on Stack Overflow
See other posts from Stack Overflow
or by Kieron
Published on 2010-03-31T09:59:38Z
Indexed on
2010/03/31
10:03 UTC
Read the original article
Hit count: 564
xml-serialization
|c#
Hi,
I've a requirement to serialize any class provided (decorated with the appropriate XmlElement/ XmlAttribute etc), but some of the properties may contain some sort of mark-up...usually HTML, but it could as easily be XML in the future.
When trying to serialize the class the XmlSerializer crashes.
I'd hope to be able to apply no more than an attribute to the property (currently set to XmlText) in the hope that it would wrap the content in CDATA[...]
, but that doesn't seem to work.
I've seen several 'workarounds' like the one here, but I'd hoped for something a little less impactful for the developing consumer.
Does anyone know of any 'nicer' less invasive solution...?
Thanks, Kieron
© Stack Overflow or respective owner