innerHTML and CDATA

Hi,
I am using ajax to update HTML of a div . THe ajax call returns a xml structure like:
<response>
<reponse-html><![CDATA[$HTML]]</response-html>
</response>

Where $HTML is the html that i need to set for the div.

On the javascript side I do:

var elHtml = xmlRoot.getElementsByTagName( 'RESPONSE-HTML' );
var elCData = elHtml[ 0 ].firstChild;
strHtml = elCData.data;
//also tried strHtml = elCData.nodeValue;
document.getElementById( 'my_div' ).innerHTML = strHtml;

The problem is the div displays raw HTML , rather then parsed html. By raw html I mean it displays strHtml as text with all the tags and stuff. I am using firefox.

What am I doing wrong here?
I have tried sending entity encoding too, it's still the same result.

Correction: xmlRoot is root node i.e. <Response>
[963 byte] By [venAdder] at [2007-11-20 10:59:28]
# 1 Re: innerHTML and CDATA
That is because CDATA converts < to < and > to >. So your tags won't be HTML but rather HTML entities.

EDIT: Just convert the entities back to < or >.
PeejAvery at 2007-11-8 0:43:11 >
# 2 Re: innerHTML and CDATA
Thnkas, I got rid of htmlentities(PHP) function and it seems to work now. I never knew CDATA implicitly converted < > to their counterpart entities. Thank You.
venAdder at 2007-11-8 0:44:16 >
# 3 Re: innerHTML and CDATA
You're welcome. Read a little more about that here ( http://en.wikipedia.org/wiki/CDATA). Take special note to the section titled Syntax and interpretation.
PeejAvery at 2007-11-8 0:45:12 >