A Flash Developer Resource Site

Results 1 to 20 of 40

Thread: Problem Reading XML - Help!

Threaded View

  1. #8
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    if your xml is heading towards -
    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <main>
    <news>
    <new links="link1" mytext="Welcome to 7 Clans Casino | Thief River Falls" />
    <new links="link2" mytext="Lunch and Dinner Buffets starting at $11.95" />
    </news>
    </main>

    <main>
    <news>
    <new links="link3" mytext="Thief River Falls" />
    <new links="link4" mytext="Lunch $110.95" />
    <new links="link5" mytext="Starting at 4:00pm" />
    </news>
    </main>
    you will need to loop thro' each <main></main> node counting the number of <new > nodes within each.
    you will need a nested loop to do this -
    PHP Code:
    // xml parsing.
    xmlParse = function (xmlObj) {
    aNode xmlObj.childNodes
    len1 aNode.lengthtrace(len1+" nodes - <main></main>");
        for (var 
    0i<len1i++) {
    len2 =  aNode[i].firstChild.childNodes.length; ;
        for (var 
    0j<len2j++) { trace("<main>"+i+" <new>"+j);
    trace(aNode[i].firstChild.childNodes[j].attributes.mytext);
    trace(aNode[i].firstChild.childNodes[j].attributes.links)
    }
    }
    };

    // --load xml
    myXML = new XML();
    myXML.ignoreWhite true;
    myXML.onLoad = function(){
    xmlParse(this);
    }
    myXML.load("test.xml"); 
    hth
    Last edited by a_modified_dog; 05-07-2008 at 05:39 PM.

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