开发者

Problem getting XML properly formatted

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 &lt;br /&gt;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 &lt; will be correctly read as <.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜