www.webdeveloper.com
Results 1 to 2 of 2

Thread: CDATA problem

  1. #1
    Join Date
    Apr 2009
    Posts
    11

    CDATA problem

    Hello,

    What is the different between this two codes ?

    First:

    <!DOCTYPE books [
    <!ELEMENT books (book_name)>
    <!ELEMENT book_name (CDATA)>
    ]>


    and than the in the XML file:

    <books>
    <book_name>&&&&</book_name>
    </books>

    This code cause an error.

    Second:

    <!DOCTYPE books [
    <!ELEMENT books (book_name)>
    <!ELEMENT book_name (#PCDATA)>
    ]>

    and than the in the XML file:

    <books>
    <book_name><![CDATA[&&&&]]></book_name>
    </books>

    This code is perfectly fine

    My question is way ?
    In both cases it declare that the content of the element "book_name"
    will not parsed, so why the first code cause an error ?

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    XML parsers don't work that way; the document has to be well-formed without the DTD. That's why scripts and styles in XHTML are PCDATA.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles