How do i write the literal “]]>” inside a CDATA section without it ending the section

谁都会走 提交于 2019-11-29 09:45:48

You can do it like this:

]]>]]&gt;<![CDATA[

This ends up breaking the CDATA section in two parts, but it's what you have to do.

Henrik Paul

I think

<![CDATA[]]]]><![CDATA[>]]>

is the way to go.

That is:

  • one CDATA section containing the literal string ]] (<![CDATA[]]]]>)
  • one CDATA section containing the literal string > (<![CDATA[>]]>)

In practice, there would probably be text before the first ]] and/or after the >

See more at http://en.wikipedia.org/wiki/CDATA#Uses_of_CDATA_sections

You can't. CDATA doesn't provide any way to escape characters, so those characters will always represent the end of the CDATA section. You can, however, let them end the CDATA section, add "]]&gt;" and start a new one with "<![CDATA[".

This way the String "]]>]]&gt;<![CDATA[" has almost the effect of being an escape for "`]]>" in a CDATA section.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!