I use classes (autogenerated from a schema) to generate xml documents. It has worked fine, until now, when I need to use i开发者_运维技巧nline HTML elements. I've tried several different methods, but as soon as I use the inline HTML, the "<" and ">" gets replaced with %lt; etc.
Example:
<meta>
<name>test</name>
<value>test <br />new row</value>
</meta>
becomes "destroyed" later on when trying to get it as a string for database storage, the value is changed to:
<value>test <br />new row</value>
How is it possible to keep the angle brackets intact?
You need to use CDATA sections for XML (or XML like) content.
The XML write is escaping the reserved characters such as <
, >
etc. If you're reading the text back using a Xml reader then your <
will be correctly read as <
.
精彩评论