lecosson / assql

Automatically exported from code.google.com/p/assql
0 stars 0 forks source link

How to return as XMLList instead of ArrayCollection #72

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This isn't a bug but rather a missing feature, i'm not sure where else to
post it so here it is:

If you want to have XML returned instead of an array do the following:

add the following code to ResultSet.as:

        // Converts ArrayCollection of data to XML
        public function getXML(arraydata:ArrayCollection):XMLList {
            var XMLStr:String = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<data>";

            for each(var node:Object in arraydata) {
                XMLStr += "<record>";
                for(var i:String in node){
                        XMLStr += "<" + i + ">" + node[i] + "</" + i + ">";
                }
                XMLStr += "</record>";
            }
            XMLStr += "\n</data>";

            return new XMLList(XMLStr);
        }

And when you want to get the results use something like:

ResultSet(data).getXML(ResultSet(data).getRows());
The above is based on Token Responder Example 2 in the examples section of
the Wiki

Original issue reported on code.google.com by beuker.m...@gmail.com on 27 Jan 2009 at 8:39