eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak

 

Introduction to XML For Web Developers
CDATA  

As we have already said, it is a pretty good rule of thumb to consider anything outside of tags to be character data and anything inside of tags to be considered markup. But alas, in one case this is not true. In the special case of CDATA blocks, all tags and entity references are ignored by an XML processor that treats them just like any old character data.

CDATA blocks have been provided as a convenience measure when you want to include large blocks of special characters a character data, but you do not want to have to use entity references all the time. What if you wanted to write about an XML document in XML! Consider the following example in which you would have an example tag in your XML Guide written in XML:

<EXAMPLE>
&lt;DOCUMENT&gt;
&lt;NAME&gt;Coleen Merriman&lt;/NAME&gt;
&lt;EMAIL&gt;cm@mydomain.com&lt;/EMAIL&gt;
&lt;/DOCUMENT&gt;
</EXAMPLE>

As you can see, you would be forced to use entity references for all the tags. YUCK!

To avoid the inconvenience of translating all special characters, you can use a CDATA block to specify that all character data should be considered character data whether or not it "looks" like a tag or entity reference.

Consider the following example:

<EXAMPLE>
<![CDATA[
<DOCUMENT>
<NAME>Coleen Merriman</NAME>
<EMAIL>cm@mydomain.com</EMAIL>
</DOCUMENT>
]]>
</EXAMPLE>

As you might have guessed, the character string ]]> is not allowed within a CDATA block as it would signal the end of the CDATA block.

Previous Page | Next Page | Table of Contents