Reputation: 2941
Is this a valid XML?
<foo>
<![CDATA[<bar>]]>
<sibling></sibling>
</foo>
Can all XML Parsers parse this?
Upvotes: 2
Views: 45
Reputation: 9164
That XML fragment is certainly well formed. Whether it is valid depends on the XML schema (or DTD) that you use to validate it.
Upvotes: 0
Reputation: 89325
CData alongside other node is fine, it doesn't break well-formed-ness of the XML document. Given that fact, all decent XML parser should be able to parse such structure.
From XML 1.0 specification :
[Definition: CDATA sections may occur anywhere character data may occur; they are used to escape blocks of text containing characters which would otherwise be recognized as markup. CDATA sections begin with the string
" <![CDATA[ "
and end with the string" ]]> "
:].
Upvotes: 1