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

**URL:** https://forum.kirupa.com/t/parser-package-xmlloader-and-xmlparser-class-simple-solution-to-some-xml-problem/197688
**Category:** Uncategorized
**Created:** [August 18, 2006, 7:10am UTC](https://forum.kirupa.com/t/parser-package-xmlloader-and-xmlparser-class-simple-solution-to-some-xml-problem/197688 "2006-08-18T07:10:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jopiruizen](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@jopiruizen](https://forum.kirupa.com/u/jopiruizen)
#### Post date: [August 18, 2006, 7:10am UTC](https://forum.kirupa.com/t/parser-package-xmlloader-and-xmlparser-class-simple-solution-to-some-xml-problem/197688/1 "2006-08-18T07:10:25Z")

</div>

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

```auto

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

```

METHODS.  
loadXML([url:String](http://www.kirupa.com/forum/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

```auto

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

```auto

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
