Reputation: 18387
Pretty simple question, I'm writing an XML document and i'm not sure how to write "]]>" without it being seen as the end of the section.
Upvotes: 10
Views: 1801
Reputation: 67703
I think
<![CDATA[]]]]><![CDATA[>]]>
is the way to go.
That is:
]]
(<![CDATA[]]]]>
)>
(<![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
Upvotes: 9
Reputation: 308001
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 "]]>
" and start a new one with "<![CDATA[
".
This way the String "]]>]]><![CDATA[
" has almost the effect of being an escape for "`]]>" in a CDATA section.
Upvotes: 5
Reputation: 992707
You can do it like this:
]]>]]><![CDATA[
This ends up breaking the CDATA section in two parts, but it's what you have to do.
Upvotes: 19