PDA

View Full Version : Parsing response.responseXML in a browser-independent way



kovtik
31 Oct 2006, 11:35 AM
I am using YAHOO.util.Connect.asyncRequest method and get response with the following response.responseText value:

<?xml version="1.0" encoding="UTF-8"?>
<data>
<![CDATA[
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" >
<param name="allowScriptAccess" value="sameDomain" />
</object>
]]>
</data>How can I retrieve the following part of xml

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" >
<param name="allowScriptAccess" value="sameDomain" />
</object>in a browser-independent way?

response.responseXML.text works fine in IE and Opera, but doesn't work in FF
response.responseXML.documentElement.textContent works fine in FF and Opera but doesn't work in IE

Is there a way to parse response.responseXML in a browser-independent way?

jack.slocum
31 Oct 2006, 2:43 PM
You could try:

response.responseXML.getElementsByTagName('data')[0].firstChild.nodeValue;

Obviously not ideal but it should work.

tryanDLS
31 Oct 2006, 4:32 PM
or


var s ='';
if (result.responseXML.xml)
s = result.responseXML.xml; // IE
else
s = (new XMLSerializer()).serializeToString(result.responseXML); // Mozilla

not sure if the Mozilla way works in Safari too

warkesm
17 Feb 2012, 6:37 AM
Thank You Jack ! Your post helped me :)
I'm using Sencha Touch 2 Beta 2 and not sure which functions can be used with it and which can not.
- Sachin Warke