Convert XML to Array of objects

Hi,

I found a good class to convert XML to Array of Objects just like SimpleXMLSecoder do in flex.

The problem is the class does not convert it to array if there is only 1 node. I tried to modify it without success.

Please can someone help me with this.

Attached are the source files.

e.g.


import eu.rotundu.xml.*;

var s:SimpleXMLDecoder = new SimpleXMLDecoder(true);

/*
var list:XML = <books>
        <book publisher="Addison-Wesley" name="Design Patterns" />
        <book publisher="Addison-Wesley" name="The Pragmatic Programmer" />
        <book publisher="Addison-Wesley" name="Test Driven Development" />
        <book publisher="Addison-Wesley" name="Refactoring to Patterns" />
        <book publisher="O'Reilly Media" name="The Cathedral & the Bazaar" />
        <book publisher="O'Reilly Media" name="Unit Test Frameworks" />
</books>;
*/

var list:XML = <books>
        <book publisher="Addison-Wesley" name="Design Patterns" />
</books>;

var result:XMLDocument = new XMLDocument();
result.ignoreWhite = true;
result.parseXML(list.toString());


var o:Object = s.decodeXML(result.firstChild);

trace(o.book.length)

The above code returns length if I use the commented list. I want to create 0 index Array if there is one element only.