Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

1.9 CDATA sections

<![CDATA[ text content possibly containing literal < or & characters ]]>

CDATA sections can be used to "block escape" literal text when replacing prohibited characters with entity references is undesirable. CDATA sections can appear inside element content and allow < and & character literals to appear. 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 processor recognizes inside a CDATA section is the closing character sequence ]]>. The character sequence that ends a CDATA section ]]> must not appear inside the element content. Instead, the closing greater-than character must be escaped using the appropriate entity &gt;. CDATA sections cannot be nested.


CDATA section

<![CDATA[ They're saying "x < y" & that "z >
y" so I guess that means that z > x ]]>

Use of literal less-than characters in a CDATA section

  • + Share This
  • 🔖 Save To Your Account