A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: XML into Array for Datagrid

  1. #1

    XML into Array for Datagrid

    I am attempting to load some xml data into an array and then show that data in a Datagrid. I think I need to create a multidimensional array but I am stumped at this point.

    Here is what the grid should look like:

    [ItemNumber] [SystemUrl]
    12365 TestingSomeUrl.com
    12366 TestingSomeUrl2.com


    Here is my actionscript:

    Code:
    MyXML = new XML();
    MyXML.ignoreWhite = true;
    MyXML.onLoad = function(success) {
    	if(success) {
    	//arrays
    	dB = new Array();
    	//parsing
    	for (i=0; i< _root.MyXML.firstChild.childNodes.length; i++) {
    	dB[i] = _root.MyXML.firstChild.childNodes[i].attributes;
    	}
    	}
    }
    MyXML.load("TableData.xml");
    
    function setData() {
    	grid.setDataProvider(dB);
    }
    And the XML

    Code:
    __?xml version="1.0" encoding="iso-8859-1"?>
    __main>
    ________item1 ItemNumber="12364" SystemUrl="http://testingthis.com?1236" />
    ________item2 ItemNumber="12365" SystemUrl="http://testingthis.com?1237" />
    __/main>
    Feel free to email me with flash problems, jobs, rants, whatever.

  2. #2
    Figured it out, now I just need to know how to rename the column headers!

    Code:
    MyXML = new XML();
    
    MyXML.ignoreWhite = true;
    
    MyXML.onLoad = function(success) {
    
                if(success) {
    
                //arrays
    
                dB = new Array();
    
                //parsing
    
                for (i=0; i< _root.MyXML.firstChild.childNodes.length; i++) {
    
                dB[i] =new Array( _root.MyXML.firstChild.childNodes[i].attributes.ItemNumber,_root.MyXML.firstChild.childNodes[i].attributes.SystemURL);
    
                }
    
                }
    
    }
    
    MyXML.load("TableData.xml");
    
     
    
    function setData() {
    
                grid.setDataProvider(dB);
    
    }
    Feel free to email me with flash problems, jobs, rants, whatever.

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