Parser package(XMLLoader and XMLParser class) Simple solution to some XML Problem

NOTE: THE following objects are functional only in 3 Layer XML.(You may picture it as table
data)…
parser

  • XMLParser
  • XMLLoader

XMLLoader: Load external XML and then parse it and convert it to XMLParser object.

Constructor


import parser.*;
var xmlloader:XMLLoader = new XMLLoader();

METHODS.
loadXML(url:String) - load a specify xml and it will automatically convert xml to XMLParser
object.

addListener: create a listener to listen to onParseComplete event whick check whether the
XMLoader had finished on loading and parsing the xml.
removeListener: remove a listener.
getParseObject():XMLParser : A method that will return the XMLParser object.
Example:Usage


import parser.*;
var xmlloader:XMLLoader = new XMLLoader();
var objl: Object = new Object(); // the object that will listen to the onParseComplete event
var parse:XMLParser = new XMLParser();
objl.onParseComplete = function() {
 parse = xmlloader.getParseObject(); // get the xml as parse object
 parse.viewDetails(); // trace a table like collection of data and its value
};
xmlloader.addListener(objl); //adding the listener
xmlloader.loadXML("setup/enemy_collection.swf"); // loads the XML

XMLParser Object: Convert XML to an array like table for easier access.
Constructor


var parseobj:XMLParser = new XMLParser();

METHODS
parseNode(xmlnode:XMLNode) : convert XMLNode to 2 Dimensional array.
xmlnode should always be the first child of the XML object
getNodeValue(index:Nubmer, ColName:String):String
index: Just like in table, index can be view as the row.
ColName: Just like in table, nodename can be view as the column.
getTotalIndex: Return a the Lenght of the XMLParser

viewDetails: trace a table like collection of data and its value


editNode(index:Number, colName:String, newvalue:String): edit a certain value in the
XMLParser object.
index: ROW number
COlName: Then Name of the Column
newvalue: the value to replace the existing value
deleteNode(index:Number): delete specify row in XMLParser…
toXML(rootnode:String, childnode:string):Void Convert the XMLParse object to XML String that
can be parse to XML.
rootnode: The xml tag that will appear in the rootnode of your xml.
chilnode: the xml tag that will serve as the carrier of each child element of the parser…
getXML():String = return the xmlstr after using the toXML method of the XMLParser.

ANyway included here was the updated version of the parser package including the XMLLoader Class