Home >>XML Tutorial >CDATA vs PCDATA
CDATA: (Data on Unparsed Character): CDATA includes the text that is not further interpreted in an XML document. Tags are not viewed as markups within the CDATA file, and individuals are not expanded.
Let's take an example for CDATA:
<?xml version="1.0"?>
<!DOCTYPE employee SYSTEM "employee.dtd">
<employee>
<![CDATA[
<firstname>phptpoint</firstname>
<lastname>Noida</lastname>
<email>phptpoint@phptpoint.com</email>
]]>
</employee>
In the above CDATA illustration, CDATA is used for having the data / text unparsed just after the employee part, so it will offer the employee's value:
<firstname>phptpoint</firstname>
<lastname>Noida</lastname>
<email>phptpoint@phptpoint.com</email>
PCDATA: (Parsed Character Data): XML parsers are used in an XML document to interpret all of the data. PCDATA stands for data of the Parsed Character. PCDATA is the text that a parser must read from. Tags within the PCDATA are viewed as markups, and individuals are expanded.
In other terms, you can assume that a parsed character data implies that the XML parser must analyze the data to make sure that if it includes anything which should be replaced, it does not affect the entity.
Let's take an example:
<?xml version="1.0"?>
<!DOCTYPE employee SYSTEM "employee.dtd">
<employee>
<firstname>phptpoint</firstname>
<lastname>Noida</lastname>
<email>phptpoint@phptpoint.com</email>
</employee>
The employee variable in the above example includes 3 more components 'firstname,' 'lastname' and 'email,' so it further parses the first name, lastname and email data/text to give the employee's meaning as:
phptpoint Noida phptpoint@phptpoint.com