A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: N003 XML question...

  1. #1
    Senior Member
    Join Date
    Nov 2007
    Posts
    207

    N003 XML question...

    B4 you say it...I know I should already know this...but here goes...

    How would I extract the data attribute from the following XML into an array?

    <node>
    <node label="catagory1">
    <node label="exibitor1" data="1, 2, 3" />
    <node label="exhibitor2" data="10, 20, 30" />
    </node>
    <node label="catagory2">
    <node label="exibitor3" data="5, 7, 9" />
    <node label="exhibitor4" data="100, 200, 300" />
    </node>
    <node label="category3">
    <node label="exibitor1" data="1, 2, 3" />
    <node label="exhibitor4" data="100, 200, 300" />
    </node>
    </node>

    var newArray:Array = new Array();

    array=node.attributes.data; ???

    Thanks...

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    PHP Code:
    arr = [];
    _xml = new XML();
    _xml.ignoreWhite true;
    _xml.load("data.xml");

    _xml.onLoad = function(){
    aNode this.firstChild.childNodes;
    len aNode.length;
    for(var 
    n=0;n!=len;n++){
    len2 aNode[n].childNodes.length;
    arr[n] = [];
    for(var 
    m=0;m!=len2;m++){
    arr[n][m] = aNode[n].childNodes[m].attributes.data;
    }
    }
    };

    /* produces -

     _level0.arr = [object #1, class 'Array'] [
        0:[object #2, class 'Array'] [
          0:"1, 2, 3",
          1:"10, 20, 30"
        ],
        1:[object #3, class 'Array'] [
          0:"5, 7, 9",
          1:"100, 200, 300"
        ],
        2:[object #4, class 'Array'] [
          0:"1, 2, 3",
          1:"100, 200, 300"
        ]
      ]

    */ 

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