|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: CDATA sections in W3C XML Infoset
In this case "my software" is the Xerces DOM parser, and yes, I am
saying that this software treats <![CDATA[<a/>]]> differently from
<a/>.
yes the parser might flag all sorts of stuff like line numbers in the
source, comments etc, as well as cdata sections but why does the
application you layer over that care about cdata?
1. The DOM gives you a different node type for the former than
it gives you for the latter.
But they both have the same string content. If you give it
<![CDATA[<a>]]> or <a> then in both cases the DOM will pass you a
string of length three "<a>" in one case a CDATA node in the other a
text, but that only matters if you are some kind of editor and want to
write the file back in a way similar to the source markup.
2. If you hand the value of the node you get back for the former
to an XML parser you get a successfully parsed document;
if you hand <a/> to the parser it fails.
The text node will have the string <a> if you are seeing <a>
then you have walked over the string replacing < by > But you
don't want to linearise the string as XML you don't want > and you
don't want <
Cart








