-
itunes:image Nodes
I'm building a podcast player, and one of the features i'm putting in it, is the ability to load the itunes image from the podcast, into a mc on the stage. But i'm having a problem. I'm using for statements to traverse, and search throught the xml for the node name "itunes:image", and it's not finding anything. Here's my code:
PHP Code:
var content1:XML = new XML();
content1.ignoreWhite = true;
content1.load("http://tsoya.libsyn.com/rss");
content1.onLoad = function (success){
if (success){
trace ("XML Loaded");
trace (content1.firstChild.firstChild.childNodes[15].nodeName);
for (var i=0; i<content1.firstChild.childNodes.length; i++){
for (var j=0; j<content1.firstChild.childNodes[i].childNodes.length; j++){
for (var k=0; k<content1.firstChild.childNodes[i].childNodes[j].childNodes.length; k++){
if (content1.firstChild.childNodes[i].nodeName == "itunes:image"){
trace (content1.firstChild.childNodes[i]);
}
if (content1.firstChild.childNodes[i].childNodes[j].nodeName == "itunes:image"){
trace (content1.firstChild.childNodes[i].childNodes[j]);
}
if (content1.firstChild.childNodes[i].childNodes[j].childNodes[k].nodeName == "itunes:image"){
trace (content1.firstChild.childNodes[i].childNodes[j].childNodes[k]);
}
}
}
}
}
}
I know the rss feed has an itunes:image tag in it, so why can't this script find it?
you can look at the actual feed here. I really hope someone can help me.
Btw, could it being a self-closing tag have anything to do with it?
Last edited by Illidin; 10-07-2005 at 04:57 PM.
-
I do think it has something to do with the self closing tags.
-
Senior Member
When I got to the URL you are using I cannot find podcast xml, I get a html page asking for donation instead. Could this be the problem?
Thanks
Luke
-
No, they must have noticed all of the extra traffic, and shut down the feed....
But it doesn't just happen with that rss feed. Here try this one:
http://leo.users.sonic.net/twit.xml
If you look at the feed, you'll see a self closing tag with the node name itunes:image, and an attribute named href. Now if you test out my code with that feed it won't work. It's driving me crazy!
-
So, does anyone have any idea why flash can't recognize that tag?
I've tried with flash8 and mx2004...
-
Senior Member
Why don't you add a trace statement before each of the if statements. Flash might be ignoring the namespace part of the node name (itunes in itunes:image). If you trace before each of your if statements you will get an idea what your code is looking at.
Thanks
Luke
-
Flash is seeing the if statements just fine, it just doesn't want to recognize the itunes:image nodes. I mean, can anyone just try out the code I pasted, and let me know if it works for you? And if there's a better way to do this, can someone post how? This is really irritating me.
-
Senior Member
Ok I had a look at your code and what was happening in the flash debugger. When stepping through watching what happens, when it gets to an itunes:image tag, because it does not have any child nodes it does not step into your last for loop (k), and therefore never checks your if statements.
When I first saw you code I was wondering why have never seen looping through xml done like that before, now I know why. The easy fix is not to have your 3 if statements in the final for statement but to have an if statement after each of the for statements.
Thanks
Luke
-
Originally Posted by tupps
Ok I had a look at your code and what was happening in the flash debugger. When stepping through watching what happens, when it gets to an itunes:image tag, because it does not have any child nodes it does not step into your last for loop (k), and therefore never checks your if statements.
When I first saw you code I was wondering why have never seen looping through xml done like that before, now I know why. The easy fix is not to have your 3 if statements in the final for statement but to have an if statement after each of the for statements.
Thanks
Luke
Ahhh. Thank you tupps, you're a life saver.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|