Hi, a really good XML/XMLList guide is here by Senocular
Originally Posted by Senocular
XML instances contain one root node which can contain any number of child nodes. XMLList instances are a collection or list of XML instances or XML nodes.
Deciding which to use depends on what you are doing, plus a lot of the functions return XMLLists. It's not really a case of choosing which to work with, you'll more than likely be working with both.
AS3 has a really powerful built in system for accessing XML data called E4X. I won't get into it too much as other people have explained it far better than I could. One such resource which has good examples is this guide on Sephiroths site
So an example of using it in a function:
public function loadTitle(xml:XML):String
Make sure to remove the event listeners when you are done with them:
private function xmlError(e:IOErrorEvent):void
trace("IOError at the XML");
private function xmlLoaded(e:Event):void
Wrapping the whole lot in its own class could be overkill. Say I make a slideshow that loads a list of image filenames from an XML file. I only need to load the XML file once. I would just have to the code to do that in my main class. Wrapping basic things can add overhead to your application as you are putting extra steps in there which can affect performance if you are heavily calling those functions over time. Then once I'm done with the XML, say after all the slideshow images have been loaded, I can remove references to the XML object such as event handlers, leaving it free to be cleared by the garbage collector.
On the other hand, if you are going to be reloading the XML frequently and then performing actions against it that you don't really want cluttering up your main class then wrapping it up is a good idea. Say for instance each time you get the title you want to do some checking with it:
public function petSounds(xml:XML):void
trace("Dogs go quack");
trace("Cats go moo");
trace("Birds go ROOOOAAAARR!");
Even then though, I'd only really use a wrapper class if I was going to have several functions like this. Sometimes, breaking things up into smaller and smaller pieces sucks, that's just my opinion.