I have a xml file - it is machine generated. Basically it put everything into CDATA (sample below)- so text inside a CDATA section is ignored by the parser. but does this not defeat the purpose of using XML?
<desc> - <![CDATA[ The slide show blah blah blah. ]]> </desc> or <content_id> - <![CDATA[ 00B0D0E1E189087CDCD80201000009B4 ]]> </content_id>
The main purpose of using CDATA is suppose you have a text with lot of "<" and &&, then instead of writing < ( entity reference ) u can use CDATA so that parser will ignore that. say you have some line like this a<b && a>c && a<d . for parser < is a start of new element. hth sunitha
Joined: Mar 16, 2002
sunitha, Thanks for your reply. So then if all text is inside CDATA tags what good is it to be in a XML file. Is it not defeating the purpose of a XML file?
If the text within a CDATA block would have been interpreted by the XML parser as a single text element anyway, we have lost nothing. If the text would have been interpreted as something else (two XML elements, invalid XML structure causing a parsing error), we have prevented a possibly fatal error.
In preparing the scripts for on-line mock exams I use CDATA to enclose the text of questions, options and answers because the text may contain symbols that XML parsers recognize. The XML tags provide the structure of the question - I really don't see the point of your objection. Bill
William, I don't realy object, it was just that I didn't understand why one would do this. Although I do know the purpose of it, I and had never seen it used this way. But okay, would you call it good xml programming / standards? Thanks for you reply. MM