# Array prototype not working as I'd expect..help please

**URL:** <https://forum.kirupa.com/t/array-prototype-not-working-as-id-expect-help-please/79073>\
**Category:** flash\
**Created:** [February 10, 2005, 5:53pm UTC](https://forum.kirupa.com/t/array-prototype-not-working-as-id-expect-help-please/79073 "2005-02-10T17:53:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![codergirl](https://avatars.discourse-cdn.com/v4/letter/c/ee59a6/32.png) [@codergirl](https://forum.kirupa.com/u/codergirl)\
**Post date:** [February 10, 2005, 5:53pm UTC](https://forum.kirupa.com/t/array-prototype-not-working-as-id-expect-help-please/79073/1 "2005-02-10T17:53:40Z")

</div>

Hi, I created a prototype function for the Array object. It’s supposed to load and parse an XML file, then take all the values from the XML file and convert them to objects, which I then want to push to the array that called the function. However, I can’t seem to get it to work. The function itself seems to work, but the push to the array does not. Can anyone take a look at this code and give me hand? (code below)

Thanks!  
Sarah

Array.prototype.xmltoArrObj = function( path ) {

```
var xmlurl:String = "nav/" + path + ".xml";
var attr:String = "";
var val:String = "";
var my_xml = new XML;

my_xml.ignoreWhite = true;
my_xml.onLoad = function() {
    if ( success == false ) {
        return;
    }

    // create an array of all the childNodes of the firstChild
    thisTree = this.firstChild.childNodes;

    for ( var n=0; n&lt;thisTree.length; n++ ) {

        // extract attributes
        attr = thisTree[n].attributes.id;

        // extract nodeValues
        val = thisTree[n].childNodes[0].nodeValue;
        // trace( "Attr: " + attr );
        // trace( "Val: " + val );

        // create an object to store the key/value pairs
        odata = { id: attr, val: val };
        trace ( "Object " + n + " is " + odata.val );

        // add the object to the array
         this.push(odata);

    }
}

my_xml.load( xmlurl );

```

};
