ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing

ExpertRating Home
ExpertRating Benefits
Recommend ExpertRating
Suggest More Tests
Privacy Policy
XML Tutorial - Index
XML Tutorial - Introduction to XML
XML Tutorial - How XML interact with data?
XML Tutorial - How to write first XML document
XML Tutorial - What are XML Elements and Attributes?
XML Tutorial - What is XML Schema and DTD?
XML Tutorial - Which Browser support XML?
XML Tutorial - XML and Styles
XML Tutorial - Embedding XML in HTML
XML Tutorial - Working with XML Parser
XML Tutorial - Working with CDATA

Online Personal Trainer Certification
Personal Trainer Certification (Spanish)
Six Sigma Certification
Find a Personal Trainer
Project Management Certification
Six Sigma Certification
Six Sigma Black Belt Certification
Master Black Belt Certification
Six Sigma Green Belt Certification
Life Coach Certification
Lean Management Certification
Lean Six Sigma Certification
First Aid Certification
CPR Certification
Yoga Certification
Aerobics Certification
Pilates Certification
Business Analyst Certification
SEO Certification
Online Business Writing Course & Certification
Makeup Artist Certification
Baby Sitting Course & Certification
Time Management Certification
Health Club Management Certification
Medical Coding Certification
Medical Billing Certification
Business Analysis Course
Master Trainer Certification
Total Quality Management Certification
Kaizen Certification
Creative Writing Certification
Event Management Certification
Test Search by Job Title
Administrative Assistant Certification
Virtual Assistant Certification
  All Online Courses


  Home > Courses, Tutorials & eBooks > XML Tutorial > Working with CDATA

XML Tutorial - Working with CDATA

Page 1 of 1
In this chapter you will learn
  • How to escape characters?
  • What is CDATA?
  • How parsing is different for CDATA?


Escape Characters for XML

If you want to use any of the special characters, such as, &, <, >," , etc., as normal characters, you must "escape" them by using the general entities that present them. To escape a character means to conceal it from a subsequent software or process. It is often used in computing terms to refer to prefixing certain characters in programming languages with a special character string to prevent them from being interpreted as special characters. In the following table, some pre-defined general entities are shown :

                   Character                                                 Replacement
                          & &amp;
                           ' &apos;
                          > &gt;
                          < &lt;
                           " &quot;

What is CDATA?

CDATA is an acronym for Character DATA. CDATA section is a part of an XML document in which markup is not interpreted as markup, but is passed to the application as it is. In other words, CDATA sections are used to escape blocks of text containing characters which would otherwise be recognized as markup. You can escape markup characters by using the predefined entities and character references. Replacing every markup character in a piece of text could be a long and tedious process. Besides, there might be cases when you want to keep all those characters exactly as they are. And the way to do this is to use a CDATA section.

All tags and entity references are ignored by an XML processor that treats them just like any character data.

CDATA blocks has been provided as a convenience measure when you want to include large blocks of special characters as character data.


    <![CDATA[ This is a text containing <5 lines> character data &!%#  and it leaves the XML processor alone!]]>

You cannot put one CDATA section inside another.

Nothing that appears between the opening tag (<![CDATA[ ) and the closing tag ( ]]> ) will be recognized as markup.

Comments are not recognized in a CDATA section.

CDATA does not work in HTML.

All text in an XML document will be parsed by the parser. Only text inside a CDATA section will be ignored by the parser.

How Parsing is different for CDATA?

The Parsing of CDATA is different from any other data as the XML processor does not parse what is inside a CDATA section, except to look for the CDATA section's closing delimiter ']]>'. So, the user can include text just as he wants it to appear.

Data inside a CDATA section is just plain character data, which is unparsed data. The XML parser skips the text within the CDATA section, pastes the enclosed text block into its output, and then "forgets" a CDATA section ever existed.



In this chapter you have learnt:

  • Escaping special characters while using them.
  • About CDATA.
  • Parsing for CDATA


Review Questions

Fill in the Blanks

  1. ________ is an acronym for character DATA.
  2. > character is replaced with _______, while escaping characters.
  3. _______ is used as CDATA section closing delimiter.



  1. CDATA
  2. >
  3. ]]>

True or False

  1. Anything written inside a CDATA section is escaped by the parser.
  2. Mark-up characters cannot be escaped.
  3. CADTA section can be nested.
  4. Comments are not recognized in a CDATA section.
  5. HTML supports CDATA.


  1. True
  2. False
  3. False
  4. True
  5. False
Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
© ExpertRating 2015. All Rights Reserved.