PDA

View Full Version : [FMX] Amazon.com API into XML



DJ Lex
June 13th, 2003, 06:45 PM
Hi Folks!

I'm 99% there but I missing something and have spent to much time trying to get this to work. Hopefully someone can point out my obvious mistake...

The XML document I'm testing with:

http://xml.amazon.com/onca/xml3?t=webservices-20&dev-t=djlex-20&KeywordSearch=Bolshoi&mode=music&type=heavy&page=1&f=xml

I'm trying to target the < ImageUrlSmall >:

function amazonLoad() {
amazonimage = (amazonXML.childNodes[0].childNodes[3].childNodes[6]);
}

When I trace amazonimage I get:

< ImageUrlSmall >http://images.amazon.com/images/P/B00002DF9J.01.THUMBZZZ.jpg< /ImageUrlSmall >


When I add the .nodeValue:

function amazonLoad() {amazonimage = (amazonXML.childNodes[0].childNodes[3].childNodes[6].nodeValue);
}

amazonimage traces as null.

So, how do I get just the value?

Thanks,
Lex

DJ Lex
June 14th, 2003, 02:29 PM
Is this topic not exciting? ;)

lostinbeta
June 14th, 2003, 02:49 PM
Try changing nodeValue to firstChild

DJ Lex
June 16th, 2003, 12:57 PM
lostinbeta,

That did the trick! Thanks! Where's your tip jar? ;)

So, can you explain why firstChild gives me the data and not nodeValue?

lostinbeta
June 16th, 2003, 02:38 PM
nodeValue returns the nodeType value of the current XML node, I believe it returns 1, or 3. Where 1 means it is an XML Element and 3 means it is a text node. Or something along those lines.


firstChild gets the value of the first child inside the parent node. In this case your parent node childNodes[6] , and the firstChild in childNodes[6] would be the text contained within that nodes tag (given there are no more nodes within that childNode).


I am VERY bad at explaining stuff like this, there are a few XML in Flash tutorial at kirupa.com if you want to check them out.

DJ Lex
June 16th, 2003, 02:48 PM
BTW, I'll be using this code to display the current playing album artwork in my banner combined with the other dynamic data from my webcast.