Forum Moderators: open

Message Too Old, No Replies

Getting back XML DOM Info

Problems using nodeName and nodeValue.

         

Ninjabear

6:45 pm on Jan 22, 2008 (gmt 0)

10+ Year Member



I have a XMLHTTPResponse function like this which receives the returning XML and extracts the information for processing.

It seems to work fine and I can traverse my tree and print out nodeName(s) but not nodeValue(s). What am I doing wrong? My firebug extension is showing me that my XML returned the information fine.

Here is my XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<products>
<product pr_id="1">
<name>washing machine</name>

<details>hoover washing machine, 3yr warranty etc</details>
</product>
</products>

Nibinaear

[edited by: tedster at 10:11 pm (utc) on Jan. 22, 2008]

Fotiman

7:41 pm on Jan 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




var pr_name= product_node.firstChild.nodeValue;
var pr_details= product_node.firstChild.nextSibling.nodeValue;

Here's what you're getting:


<products>
<product> <-- This is product_node.firstChild
...
</product>
<product> <-- This is product_node.firstChild.nextSibling
...
</product>
</products>

I think what you want is a child of the firstChild.