CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Ajax and Design (http://www.codingforums.com/forumdisplay.php?f=55)
-   -   Help getting data out of responseXML (http://www.codingforums.com/showthread.php?t=118230)

acroporas 07-07-2007 10:47 PM

Help getting data out of responseXML
 
I want my javascript to recieve an xml page containing two bits html code to insert into various places in the page.

example xml page
Code:

<?xml version="1.0" ?>
  <root>
    <image><img src="images/image1.jpg" class="imageclass" /></image>
    <exif>
<table>
<tr><td>Head</td><td>Data</td>
.....
<tr><td>Head</td><td>Data</td>
</table>
    </exif>
</root>

I am pretty confident that I am sucessfully reciving the file as I can get the following.

window.alert(ajaxreq.responseXML);
// displays "[object XMLDocument]" in firefox
// displays "[object]" in IE7

window.alert(ajaxreq.responseXML.xml);
// displays the contents of the xml file in IE7
// displays "undefined" in firefox

Seems so good so far....
But that is far as I can get.

When I try
window.alert(ajaxreq.responseXML.getElementsByTagName("image")[0].nodeValue);
//returns null in both IE and Firefox.....

Am I doing something wrong? How do I get the contents of <image> and <exif> nodes so that I can insert them into my page?

glenngv 07-08-2007 08:38 PM

Code:

var xmlDoc = ajaxreq.responseXML.documentElement;
alert(xmlDoc.getElementsByTagName("image")[0].nodeValue);



All times are GMT +1. The time now is 02:43 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.