A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: itunes:image Nodes

  1. #1
    Junior Member
    Join Date
    May 2005
    Posts
    15

    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=0i<content1.firstChild.childNodes.lengthi++){
                for (var 
    j=0j<content1.firstChild.childNodes[i].childNodes.lengthj++){
                    for (var 
    k=0k<content1.firstChild.childNodes[i].childNodes[j].childNodes.lengthk++){
                        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.

  2. #2
    Junior Member
    Join Date
    May 2005
    Posts
    15
    I do think it has something to do with the self closing tags.

  3. #3
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    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
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  4. #4
    Junior Member
    Join Date
    May 2005
    Posts
    15
    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!

  5. #5
    Junior Member
    Join Date
    May 2005
    Posts
    15
    So, does anyone have any idea why flash can't recognize that tag?
    I've tried with flash8 and mx2004...

  6. #6
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    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-XML FAQ
    http://www.tupps.com/flash/faq/

  7. #7
    Junior Member
    Join Date
    May 2005
    Posts
    15
    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.

  8. #8
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    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
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  9. #9
    Junior Member
    Join Date
    May 2005
    Posts
    15
    Quote 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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center