Question about XML

Posted on 2011-10-25
Last Modified: 2012-08-13
Please explain the name of this format and what exactly it means?


Question by:newbieweb
    LVL 9

    Assisted Solution

    The term CDATA comes from the SGML world, which is the complex predecessor of XML and was used to describe the original HTML 2, 3 and 4 specifications. The term is short for Character Data and means that the data contains of characters, and should not be parsed. Tags, entities, attributes, processing instructions inside CDATA are treated as text, not as XML elements.

    For more information, please have a look at this link:

    Author Comment

    LVL 60

    Accepted Solution

    put simple:
     a "CDATA section"  is a special text node that allows you to put special XML characters in a text node without escaping them
    Important to realize is that it is  a text node
    Note that there is not necessarily a relation with SGML's "CDATA", see below
    see my example in code pane

    I have some observations with Tehzar's answer
    well, allthough not really wrong this definition is a bit weird.
    In XML everything stems from SGML, so also the term "CDATA" does, as does "element", "attribute", "entity", "DTD", "PCDATA"
    Most of these terms did not suffer the same amount of changes going from SGML to XML, as CDATA does
    and CDATA as element content has vanished. (In HTML there is a SCIPT tag that is declared by DTD to be CDATA, meaning CDATA section without the start and end indicator, but that is no longer allowed in XML)
    What you are looking at is a CDATA SECTION, CDATA, but with explicit markers

    Where your definition goes wrong is with the HTML specs. reference
    HTML2, HTML3 and HTML4 had perfectly valid SGML DTDs, they just required some changes to the reference concrete syntax in the SGML declaration
    So that part of your definition is simply wrong .
    What makes CDATA sections usefull in XML for HTML? an IMG does not need closure in HTML, it does not in SGML (html is perfectly valid SGML and SGML allows end tag omissions), but is not valid XML, wince XML does not allow end tage omission. So it is convenient to stuff an piece of HTML as a textnode in a CDATA section (personally I hate that)

    Note that he full refrence you posted has many inconsistencies like this one
    <foo><![CDATA[special & < > without escaping]]></foo>
    is exactly the same in XML terms as
    <foo>special &amp; &lt; &gt; without escaping</foo>
    It is a convenience to help you type element content fast that contains a lot of sensitive characters
    so it is (ab)used a lot for putting html inside xml
    (which often is an error becaus eyou loose structure, you flatten the html to a text node)
    is equal to

    Open in new window

    LVL 60

    Expert Comment

    by:Geert Bormans
    please note that you accepted an answer that is not correct :-)

    Author Comment

    I have requested the question be re-opened so Tehzar can defend his answer or lose the points to Gertone.


    Author Closing Comment

    Thanks for the clarification.
    LVL 60

    Expert Comment

    by:Geert Bormans
    LVL 9

    Expert Comment

    I didn't realize this was going to turn into a dance off...however, if you would have followed the link supplied earlier, you would have found that it validates my answer.


    LVL 60

    Expert Comment

    by:Geert Bormans
    Hi ZaR,

    Of course I did follow the link, and read it in detail up to the end. I would not comment on an article without absorbing its content.
    I actually know the author in person, so I bet we will have a discussion soon about the flaws in the article,
    I think he realises there are some, note this at the top of the current version of his article:
    "Update: this post is under review and is being rewritten, it may change without notice. This notice will disappear when the rewrite is over."

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
    Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now