parsing xml in flash

import ginner.GDispatcher
class flashdb.utils.ParserXML extends XML {
var target:MovieClip
var xmlobj:XML
var lista:Array
var ref:Object

public var addEventListener:Function;
public var removeEventListener:Function;
private var dispatchEvent:Function;

function ParserXML (targ:MovieClip, list:Array,
URI:String) {

if (!arguments) {
return;
}
GDispatcher.initialize(this);
target = targ
lista = list

xmlobj = new XML();
xmlobj[“ref”] = this;
trace (this);
xmlobj.ignoreWhite = true;
xmlobj.onLoad = onLoad;
xmlobj.load(URI);
}
function onLoad (success) {
if (success) {

var nodeXML:XML = this;
if (nodeXML.firstChild.childNodes.length!=null) {
//trace (nodeXML.childNodes[0]);
//trace (nodeXML.childNodes[1]);
//var Childvalue = “childNodes[1]”;

for (var i:Number = 0; i<nodeXML.firstChild.childNodes.length;i++){

var obj:Object = new Object()
for (var j in nodeXML.childNodes[1].childNodes[i].attributes) {
obj[j] = String(nodeXML.childNodes[1].childNodes[i].attributes[j]);

}
this.ref.lista.push(obj)
}
this.ref.dispatchEvent({target:this.ref.target, type:’onloadFinished’});
}
}else{
this.ref.dispatchEvent({target:this.ref.target, type:’onloadError’});
}

}

}

Advertisements

2 thoughts on “parsing xml in flash

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s