# Summing up nodeValues in flash with as3

**URL:** https://forum.kirupa.com/t/summing-up-nodevalues-in-flash-with-as3/256647
**Category:** Uncategorized
**Created:** [April 5, 2008, 2:49am UTC](https://forum.kirupa.com/t/summing-up-nodevalues-in-flash-with-as3/256647 "2008-04-05T02:49:19Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Tolo\_Dex](https://avatars.discourse-cdn.com/v4/letter/t/c6cbf5/32.png) [@Tolo\_Dex](https://forum.kirupa.com/u/Tolo_Dex)
#### Post date: [April 5, 2008, 2:49am UTC](https://forum.kirupa.com/t/summing-up-nodevalues-in-flash-with-as3/256647/1 "2008-04-05T02:49:19Z")

</div>

I need to know how to add up XML node values in flash such as the amount of funds and such to reach total values average values and such. _Desperately Needed_ my nodes are.

```auto

<?xml version="1.0" encoding="UTF-8"?>
<row>
    <colum>
        <First>Clive</First>
        <Last>Walters</Last>
        <Business>Abundant Life Christian Ministries</Business>
        <Address>70 Delta Park Blrd Brampton, Ontario L6T 5E9</Address>
        <Amount>5000</Amount>
        <Payment_Method>Master Card</Payment_Method>
        <Payment_Plan>One Time</Payment_Plan>
        <regDate>04-04-2008</regDate>
        <expDate>04-04-2009</expDate>
    </colum>
</row>

```

Flash code

```auto

package
{
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.xml.*;
    
    public class LoadingXML extends XMLDocument
    {
        private var my_root:MovieClip;
        
        public function LoadingXML(m:MovieClip)
        {
            my_root=m;
            this.loadXML();
        }
        private function loadXML():void
        {
            var loader:URLLoader=new URLLoader();
            loader.addEventListener(Event.COMPLETE,completeHandler);
            
            
            
            var request:URLRequest=new URLRequest('Data.xml');
            try 
            {
                loader.load(request);
            } 
            catch(error:Error) 
            {
                trace('Impossibile caricare il documento.');
            }
        }
        
        private function completeHandler(event:Event):void
        {
            var loader:URLLoader=URLLoader(event.target);
            var result:XML=new XML(loader.data);
            var myXML:XMLDocument=new XMLDocument();
            myXML.ignoreWhite=true;
            myXML.parseXML(result.toXMLString());
            var node:XMLNode=myXML.firstChild;
            var n:int=node.childNodes.length;
            my_root.First=node.nodeName;
            for(var i:int=0;i < n;i++)
            {
                var obj:Object=new Object();
                var s:Number=node.childNodes*.childNodes.length;
                for(var j:int=0;j < s;j++)
                {
                    if(i==0)
                        my_root.colonne_array.push(node.childNodes*.childNodes[j].nodeName);
                    if(j==0)
                        obj.First=node.childNodes*.childNodes[j].firstChild.nodeValue;
                    if(j==1)
                        obj.Last=node.childNodes*.childNodes[j].firstChild.nodeValue;
                    if(j==2)
                        obj.Business=node.childNodes*.childNodes[j].firstChild.nodeValue;
                    if(j==3)
                        obj.Address=node.childNodes*.childNodes[j].firstChild.nodeValue;
                    if(j==4)
                        obj.Amount='$ '+node.childNodes*.childNodes[j].firstChild.nodeValue;
                        var e:Number=node.childNodes*.childNodes[j].firstChild.nodeValue;
                        trace(e);
                    if(j==5)
                        obj.Payment_Method=node.childNodes*.childNodes[j].firstChild.nodeValue;
                    if(j==6)
                        obj.Payment_Plan=node.childNodes*.childNodes[j].firstChild.nodeValue;
                    if(j==7)
                        obj.regDate=node.childNodes*.childNodes[j].firstChild.nodeValue;
                    if(j==8)
                        obj.expDate=node.childNodes*.childNodes[j].firstChild.nodeValue;
                }
                my_root.objects_array.push(obj);
            }
            my_root.creaFirst();
            my_root.initDataGrid();
        }
    }
}

```

Please help or link me with help plz

And I do help others with the same problems, I hope this post would help others to.🙂

Leo T
