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.
The only sequence which is not allowed within a CDATA section is the closing sequence of a CDATA section itself, ]]> . Note: CDATA sections should not be used within HTML they are considered as comments and not displayed.
A CDATA section begins with the character sequence <! [CDATA[ and ends with the character sequence ]]>. Between the two character sequences, an XML processor ignores all markup characters such as <, >, and &. The only markup an XML pro-cessor recognizes inside a CDATA section is the closing character sequence ]>.
The term CDATA, meaning character data, is used for distinct, but related, purposes in the markup languages SGML and XML. The term indicates that a certain portion of the document is general character data, rather than non-character data or character data with a more specific, limited structure.
CDATA means the element contains character data that is not supposed to be parsed by a parser. #PCDATA means that the element contains data that IS going to be parsed by a parser.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With