views:

213

answers:

1

I have an xml file and a flash file. The flash file reads the xml file.

<?xml version="1.0" standalone="yes"?>
<banners>
    <banner>
     <title>Hello World</title>
     <image>http://www.search-this.com/wp-content/themes/big-blue/images/company-logos1.gif&lt;/image&gt;
     <link>http://google.com/&lt;/link&gt;
    </banner>
</banners>

Now this works:

trace(this.childNodes[0].childNodes[0].childNodes[0]);
^ shows <title>Hello World</title>

But this shows NULL:

trace(this.childNodes[0].childNodes[0].childNodes[0].nodeValue);

Why is it showing NULL?

+1  A: 

Try this:

trace(this.childNodes[0].childNodes[0].childNodes[0].childNodes[0].nodeValue);
//--------------------------------------------------^ another childNodes

Reason: The text itself is a so-called text node. It is a child of the title element (an "element node").

Cheers,

Boldewyn
By the way: The nodeValue of an element node is defined as, and hence ever and always, NULL.
Boldewyn