Question

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</image>
        <link>http://google.com/</link>
    </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?

Was it helpful?

Solution

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,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top