dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Referencing particular part of XML into Actionscript, help needed please!

  1. #1
    Fusion Of Sound
    Join Date
    Jul 2005
    Location
    Birmingham, UK
    Posts
    12

    Referencing particular part of XML into Actionscript, help needed please!

    Hi there, I'm just wondering how I would refer to the <song> attribute shown in bold below, from actionscript! Would it be something like this?
    Code:
    playlist.childNodes[0].firstChild.song
    It doesn't seem to work! Thanks

    Code:
    <?xml version="1.0"?>
    <polls>
    <poll title="Who do you think should win?">
        <answers>
        <answer>
            <name>Michael</name>
            <tally>0</tally>
            <image>www.clipart.com/test.jpg</image>
            <flash>songs/1.swf</flash>
            <song>songs/mp3s/1.mp3</song>
        </answer>
        <answer>
            <name>Sophie</name>
            <tally>0</tally>
            <image>http://www.clipart.com/test2.jpg</image>
            <flash>songs/1.swf</flash>       
            <song>songs/test2.mp3</song>
        </answer>

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Code:
    <?xml version="1.0"?>
    <polls>
    <poll title="Who do you think should win?">
        <answers>
        <answer>
            <name>Michael</name>
            <tally>0</tally>
            <image>www.clipart.com/test.jpg</image>
            <flash>songs/1.swf</flash>
            <song>songs/mp3s/1.mp3</song>
        </answer>
        <answer>
            <name>Sophie</name>
            <tally>0</tally>
            <image>http://www.clipart.com/test2.jpg</image>
            <flash>songs/1.swf</flash>       
            <song>songs/test2.mp3</song>
        </answer>
    </poll>
    </polls>
    PHP Code:
    function loadXML(loaded) {
    tmp = [];
    songs = [];
    xmlNode this.firstChild.firstChild.firstChild.childNodes;
    title this.firstChild.firstChild.attributes.title;
    trace(title);

    len xmlNode.length;
    for (var 
    i=0i<leni++) {
    tmp[i] = xmlNode[i].childNodes;
    songs.push(tmp[i][4].firstChild.toString());
    }

    for (var 
    i=0i<songs.lengthi++) {
    trace("songs["+i+"] = "+songs[i]);
    }
    };

    xmlData = new XML();
    xmlData.ignoreWhite true;
    xmlData.onLoad loadXML;
    xmlData.load("polls.xml"); 
    hth

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