Pugi! wrote:
Using AJAX I want to send some information from the server (php-page)
as XML to the client. The contents can be very divers so I have to use
XML instead of text. On one occasion the contents is html, I can put
this in a CDATA section with PHP, but how do I retrieve that
information with Javascript and put the HTML in a div ?
A CDATA section shows up as a CDATA section node (nodeType is 4) in the
DOM where the contents of the CDATA section can be accessed as e.g.
node.nodeValue
or
node.data
A CDATA section node is always a leaf node so you will find it as a
child nodes of element nodes. You can also use XPath where supported to
find the CDATA section node, XPath does not distinguish between text
nodes and CDATA section nodes, both are selected by the XPath text().
So grab the CDATA section node and put its nodeValue as the innerHTML of
a HTML div e.g.
divElement.innerHTML = cdataSectionNode.nodeValue;
--
Martin Honnen
http://JavaScript.FAQTs.com/