[英]how to pass a <![CDATA[(…)]]> String to a XML file?
I need to pass a <![cdata[something-html-formatted]]>
to a xml file where I parse it as a html email body. 我需要将
<![cdata[something-html-formatted]]>
传递给xml文件,然后将其解析为html电子邮件正文。 All is working except retrieving correctly the email body. 除了正确检索电子邮件正文之外,所有其他功能都在工作。 Say, for instance, I have a string like this:
举例来说,我有一个像这样的字符串:
<![CDATA[I need to write <b>this</b> text in <i>italic</i>]]>
I always get the result on the email like this: 我总是在这样的电子邮件中得到结果:
this</b> text in italic</i>]]> </ b>斜体字</ i>]]>
How can I pass the complete string to the XML file? 如何将完整的字符串传递给XML文件?
Thanks in advance! 提前致谢!
Simply encode it, like you would everything else, by replacing <
with <
只需像对其他所有内容一样对它进行编码,只需将
<
替换为<
and >
with >
和
>
与>
: :
<xml>
<![CDATA[I need to write <b>this</b> text in
<i>italic</i>]]>
</xml>
works fine. 工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.