6.3. Handling Verboten Characters
Listing 6-6. A Script Element That Is Not Well Formed
XML interprets the less-than (<) operator as the beginning of a new element, and from an XML viewpoint, the new tag is not well formed. Fortunately, you can use one of two methods to get around this issue: entities or CDATA sections. Each of these methods is suited to a different purpose, so let's examine each to determine which better suits our problem.
Entities. A part of me just likes to say the word entities. It's just a fun word to say, especially to a manager who is unfamiliar with XML. Just imagine someone's reaction when being told that the XML contains entities. Talk about your flashbacks to late-night horror movies! Of course, there is always the alternative: being fitted for a jacket with wraparound sleeves. Either way, you've gotten the manager's attention.
XML has five predefined entities whose purpose it to avoid well-formedness issues when encountering select common characters. Table 6-1 defines these five entities, and later topics cover how to define additional entities.
6.3.2. CDATA Sections
A CDATA section is the XML equivalent of "Pay no attention to that man behind the curtain," from The Wizard of Oz. However, there is no pesky little girl with a little dog to mess things up. Because of this, XML totally ignores whatever is within a CDATA section's tags, <![CDATA[ and ]]>, as shown in Listing 6-7.
Listing 6-7. A Well-Formed Script Element