Well, if they wanted you to be able to get
at the text within the CDATA node, they should have given you:
<AccomodationName><![CDATA[HOTEL
AC MALAGA
PALACIO]]></AccomodationName>
If they had, the text content of the node
would be:
“HOTEL AC MALAGA PALACIO”
Instead, the double-escaped it so that the
CDATA tag is part of the text:
“<![CDATA[HOTEL AC MALAGA PALACIO]]>”
Since you are getting an opaque text node
which just happens to contain some CDATA syntax, you will need to re-parse the
text node if you want to extract the text from within the CDATA brackets. To
do this, you would need to extract the string, then pass it back through
another XML parser instance which is capable of handling fragments. You could
also theoretically just extract the inner part using string manipulation
routines or RegExp.
From: Diana Castillo
[mailto:diana@hotelkey.com]
Sent: Wednesday, June 09, 2004
10:00 AM
To: xml-dev@lists.xml.org
Subject: [xml-dev] cdata
anyone know why my parser is not reading just the internal part of this
tag?
Is the cdata in the correct format?
<AccommodationName><![CDATA[HOTEL AC MALAGA
PALACIO]]></AccommodationName>