XML
  Home arrow XML arrow Page 2 - XML Basics (part 2)
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

XML Basics (part 2)
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2001-07-28

    Table of Contents:
  • XML Basics (part 2)
  • Splitting Up
  • Eating Humble PI
  • XML And Alcohol
  • The Name Game
  • An Entity In The Attic
  • Digging For Treasure
  • The Man From IDIOT
  • Endgame

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    XML Basics (part 2) - Splitting Up


    (Page 2 of 9 )

    First up, CDATA. As explained in the previous article, the XML specification considers all text enclosed within tags to be character data. There is one important exception to this - CDATA blocks.

    CDATA blocks are document sections explicitly marked as not containing markup, and are hence treated as character data by the parser. These blocks can contain pretty much anything - strings, numbers, symbols, ancient Egyptian hieroglyphics - and will be ignored by the parser.

    A CDATA block typically begins with

    <![CDATA[
    and ends with

    ]]>
    with the data enclosed within the two. Here's an example:

    <?xml version="1.0"?> <manual> <function>split(str, pattern)</function> <description>Split a string <param>str</param> into component parts on the basis of <param>pattern</param></description> <example> <![CDATA[ <? split("apple, vanilla, orange", ","); ?> ]]> </example> </manual>
    CDATA blocks make it easy to add large blocks of text (including text containing special characters, symbols or program code) to an XML document, yet have the parser treat it as regular character data. And so, while a parser might choke on this,

    <?xml version="1.0"?> <secret_message> <from>Our man in Paris</from> <to>Director, Special Operations</to> <coded_body_text> 12637 0%%348 83483 89238 82383 10341 0*049 27216 02039 84585 18127 45759 3@492 83%84 22829 238#3 92345 72310 53467 12941 92461 40149 7^&291 21271 46101 42356 74(@1 4!128 47353 #511~ 473~7 12942 38#53 45628 </coded_body_text> </secret_message>
    it will be absolutely fine with this.

    <?xml version="1.0"?> <secret_message> <from>Our man in Paris</from> <to>Director, Special Operations</to> <coded_body_text> <![CDATA[ 12637 0%%348 83483 89238 82383 10341 0*049 27216 02039 84585 18127 45759 3@492 83%84 22829 238#3 92345 72310 53467 12941 92461 40149 7^&291 21271 46101 42356 74(@1 4!128 47353 #511~ 473~7 12942 38#53 45628 ]]> </coded_body_text> </secret_message>
    Obviously, you cannot include the ending sequence

    ]]>
    within a CDATA block, as this would merely serve to confuse the parser. If you need to include this sequence within a CDATA block, it needs to be written as

    ]]&gt;


    This article copyright Melonfire 2001. All rights reserved.

    More XML Articles
    More By icarus, (c) Melonfire


     

       

    XML ARTICLES

    - How to Set Up Podcasting and Vodcasting
    - Creating an RSS Reader Application
    - Building an RSS File
    - An Introduction to XUL Part 6
    - An Introduction to XUL Part 5
    - An Introduction to XUL Part 4
    - An Introduction to XUL Part 3
    - An Introduction to XUL Part 2
    - An Introduction to XUL Part 1
    - XML Matters: Practical XML Data Design and M...
    - Practical XML Data Design and Manipulation f...
    - SimpleXML
    - XForms Basics, Part 3
    - XForms Basics, Part 2
    - XForms Basics





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway