Preserving HTML in XML

Characters like “<” and “&” are illegal in XML elements. “<” will generate an error because the parser interprets it as the start of a new element. “&” will generate an error because the parser interprets it as the start of an character entity. Some text, like JavaScript code, contains a lot of “<” or “&” characters. To avoid errors, we need to parse the code using CDATA (Character Data) like so:

<!CDATA[
xxxxxxxxxxxxxxx
]]>

This is different from commenting. Commenting skips the whole section entirely, like so:

<!–
xxxxxxxxxx
–>

which is just like HTML comments.

Like it.? Share it:
Tags:

One Response to Preserving HTML in XML

  1. Rob Rasner Facebook

    OMG; The blog site Preserving HTML in XML | LAMP How To – Open Source At Work rocks ! How have one insure that it is look this good 🙂 Incidentally did you hear Obama remarkable headlines? Thx ! Rob Rasner Facebook