Hi everyone,
Please tell me what I am doing wrong:
I have an xml data coming to my Air application that looks something like this:
-
<project name="Sales Demos" path="/Company Home/Client Spaces/Sales Demos" type="{http://www.myCo.org/model/content/1.0}folder" id="71f36dcd-b59b-11dd-8205-5992b4466fe5" modified="Nov 18, 2008 3:51:20 PM" size="" icon32="/images/icons/default.gif" viewurl=""/>
-
<project name="Something else" ...
-
etc...
-
/>
-
I want to place the XML into an ArrayCollection, so that I can sort it by the values referenced in the "name" attribute.
-
import mx.collections.Sort;
-
import mx.collections.SortField;
-
import mx.collections.ArrayCollection;
-
-
var arrColl:ArrayCollection = new ArrayCollection;
-
for each(var s:XML in tree.data.children())
-
{
-
arrColl.addItem(s);
-
}
-
-
-
/* Create the SortField object for the "data" field in the ArrayCollection object, and make sure we do a numeric sort. */
-
var dataSortField:SortField = new SortField();
-
dataSortField.name = "name";
-
dataSortField.caseInsensitive = true;
-
-
/* Create the Sort object and add the SortField object created earlier to the array of fields to sort on. */
-
var numericDataSort:Sort = new Sort();
-
numericDataSort.fields = [dataSortField];
-
-
/* Set the ArrayCollection object's sort property to our custom sort, and refresh the ArrayCollection. */
-
arrColl.sort = numericDataSort;
-
arrColl.refresh();
-
var someArrColToString:String = "<xml>";
-
for each(var XMLNodeObj:Object in arrColl)
-
{
-
someArrColToString += "<project name='" + XMLNodeObj.name +
-
"' path='" + XMLNodeObj.path + "' type='" +XMLNodeObj.type +
-
"' id='" + XMLNodeObj.id +"' modified='" +XMLNodeObj.modified +
-
"' size='" + XMLNodeObj.size +"' icon32='" +XMLNodeObj.icon32 +
-
"' viewurl='" + XMLNodeObj.viewurl +
-
"' />";
-
}
-
someArrColToString += "</xml>";
-
-
var someStringToXml:XML = new XML(someArrColToString);
-
trace("tree.data.children() "+tree.data.children()+" someArrColToString "+someArrColToString);
-
I do a trace at the end to see what I've created and the tree.data.children() has the original xml in it's original order, but this is what I get back with the trace of var someArrColToString:
-
<xml><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /><project name='' path='' type='' id='' modified='' size='' icon32='' viewurl='' /></xml>
-
Which is showing me the correct amount of project tags but the attributes are not being filled.
Do I have to do something like XMLNodeObj.attribute.name?
What am I doing wrong?
Thanx n advance,
me