A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] childNodes skipping problem

  1. #1

    resolved [RESOLVED] childNodes skipping problem

    Here is my XML:
    Code:
    <?xml version='1.0' encoding='utf-8' standalone='yes' /?>
    <root>
        <section text="Hello"></section>
        <section text="Goodbye"></section>
    </root>
    When I load with this
    PHP Code:
    var my_xml = new XML();
    my_xml.onLoad = function(success) {
        if (
    success) {
            
    aNode my_xml.firstChild.nextSibling.childNodes[1];
            
    trace(aNode);
        }
    };
    my_xml.load("data.xml"); 
    it outputs this
    Code:
    <section text="Hello" />
    I'm trying to target the next node "Goodbye", but it seems to only work if I use odd numbers. If I call it with childNodes[0]; or childNodes[2]; nothing outputs.. It's not until I use childNodes[3]; that it finds the next node

    Why is it skipping a number like that? any clues appreciated

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    your problem is due to missing this line -- my_xml.ignoreWhite = true;

    in this example i push the node attribute into an array.
    PHP Code:
    my_xml = new XML();
    my_xml.ignoreWhite true
    my_xml.load("data.xml");

    arr = [];

    my_xml.onLoad = function(success){ 
    if(
    success){ 
    aNode this.firstChild.childNodes;
    len aNode.length;
    for(var 
    n=0;n!=len;n++){
    arr.push(aNode[n].attributes['text']);
    trace("arr["+n+"] = "+arr[n]);
    }

    }; 
    hth

  3. #3
    Aha forgot about that. Thansk

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