Hiding Scripts from XML Parsers
Scripts sometimes contain symbols that have special meaning in XHTML documents, namely the & and the >. If you use these symbols in a script, you should enclose them in a CDATA section to hide them from XML parsers (the programs that ensure that the XML, or XHTML in this case, is properly written).
To hide internal scripts from XML parsers:
1. | Type <script> to begin your script as usual.
|
2. | Type <![CDATA[ to hide the script from the XML parser.
|
3. | Insert the script itself.
|
4. | Type ]]> to complete the CDATA section.
|
5. | And then type </script> to complete the script element.
|
Figure 19.19. This JavaScript script is adapted from Figure 20.1 on page 322. The CDATA section removes the special meaning from the characters ...
Get HTML, XHTML, & CSS, Sixth Edition: Visual QuickStart Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.