开发者

XmlSerializer and Mark-up (Xml or Html) [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

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

Edit:

Based on Damian's answer, I found thi开发者_运维技巧s article which shows the differences between the XmlSerializer and the DataContractSerializer - http://www.danrigsby.com/blog/index.php/2008/03/07/xmlserializer-vs-datacontractserializer-serialization-in-wcf/


Just a thought, but does the DataContractSerializer have the same problem?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜