News:

This week IPhone 15 Pro winner is karn
You can be too a winner! Become the top poster of the week and win valuable prizes.  More details are You are not allowed to view links. Register or Login 

Main Menu

XML CDATA

Started by ben2ong2, October 06, 2006, 02:55:09 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

ben2ong2

All text in an XML document will be parsed by the parser.
Only text inside a CDATA section will be ignored by the parser.
Parsed Data
XML parsers normally parse all the text in an XML document.
When an XML element is parsed, the text between the XML tags is also parsed:
<message>This text is also parsed</message>
The parser does this because XML elements can contain other elements, as in this example, where the <name> element contains two other elements (first and last):
<name><first>Bill</first><last>Gates</last></name>
and the parser will break it up into sub-elements like this:
<name>   <first>Bill</first>   <last>Gates</last></name>
You are not allowed to view links. Register or Login
You are not allowed to view links. Register or Login

ben2ong2

CDATA
Everything inside a CDATA section is ignored by the parser.
If your text contains a lot of "<" or "&" characters - as program code often does - the XML element can be defined as a CDATA section.
A CDATA section starts with "<![CDATA[" and ends with "]]>":
<script><![CDATA[function matchwo(a,b){if (a < b && a < 0) then   {   return 1   }else   {   return 0   }}]]></script>
In the example above, everything inside the CDATA section is ignored by the parser.
Notes on CDATA sections:
A CDATA section cannot contain the string "]]>", therefore, nested CDATA sections are not allowed.
Also make sure there are no spaces or line breaks inside the "]]>" string.
You are not allowed to view links. Register or Login
You are not allowed to view links. Register or Login