Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

CDATA vs PCDATA


CDATA

CDATA: (Unparsed Character data): CDATA contains the text which is not parsed further in an XML document. Tags inside the CDATA text are not treated as markup and entities will not be expanded.

Let’s take an example for CDATA:

  1. <?xml version=“1.0”?>
  2. <!DOCTYPE employee SYSTEM “employee.dtd”>
  3. <employee>
  4. <![CDATA[ 
  5.   <firstname>vimal</firstname>
  6.   <lastname>jaiswal</lastname>
  7.   <email>vimal@Kreationnext.com</email>
  8. ]]>
  9. </employee>

Test it Now

In the above CDATA example, CDATA is used just after the element employee to make the data/text unparsed, so it will give the value of employee:

<firstname>vimal</firstname><lastname>jaiswal</lastname><email>vimal@Kreationnext.com</email>

PCDATA

PCDATA: (Parsed Character Data): XML parsers are used to parse all the text in an XML document. PCDATA stands for Parsed Character data. PCDATA is the text that will be parsed by a parser. Tags inside the PCDATA will be treated as markup and entities will be expanded.

In other words you can say that a parsed character data means the XML parser examine the data and ensure that it doesn’t content entity if it contains that will be replaced.

Let’s take an example:

  1. <?xml version=“1.0”?>
  2. <!DOCTYPE employee SYSTEM “employee.dtd”>
  3. <employee>
  4.   <firstname>vimal</firstname>
  5.   <lastname>jaiswal</lastname>
  6.   <email>vimal@Kreationnext.com</email>
  7. </employee>

Test it Now

In the above example, the employee element contains 3 more elements ‘firstname’, ‘lastname’, and ’email’, so it parses further to get the data/text of firstname, lastname and email to give the value of employee as:

vimal jaiswal vimal@Kreationnext.com

Comments

comments