PCDATA In XML

PCDATA acronyms for Parsed Character Data. Data of this section is parsed by XML Parser and unlike CDATA section we can not use special character in this section. “#PCDATA” is a token used in an element declaration to declare the element as having mixed content (character data, or character data mixed with other elements). The content of the element is parsed; ‘&’ and ‘<‘ have special meaning and must be escaped if they aren’t the start of markup.
“#PCDATA” is a token used in an element declaration to declare the element as having mixed content. The content of the element is parsed; ‘&’ and ‘<‘ have special meaning and must be escaped if they aren’t the start of markup. This means if you use any unescaped special character such as & etc in a PCDATA section parser will generate error the XML file is parsed.
 
<script>
<![CDATA[
var salary;
function showSalary(amount)
{
if (amount<=5000) then
{
    salary=amount+(amount*.10);
}
else
{
    salary=amount+(amount*.08);
}
}
]]> </script>
 
remember when this script will be written inside any XML tag browser will display error while parsing this data.
Scroll to Top