Robin Berjon

XML Bad Practices

Markup In CDATA Sections

This problem is simple and requires very little explanation. Yet it occurs altogether too often. This article is part of a series based the paper on "Designing XML/Web Languages: A Review of Common Mistakes" which I presented at the XML Prague 2009 conference.

The following example should be sadly familiar to most.


  ...
  
      ...
    
  ]]>]]>]]>

There are cases in which this can be needed, oftentimes it is used to embed poorly formed HTML, and in some rarer cases, because XML is not entirely composable (the XML declaration and DTD prevent that), it is justified even for XML. But generally speaking, it is a bad idea: if the content is XML, then it should be part of the tree and not require some indirect further level of parsing.

This article is part of a series on XML Bad Practices.