Say for example, I have an XML file with 100 "person" nodes, and I want the first 30. Or possibly 51 - 100. Is there any way to do this with e4x syntax to return an XMLList?
+1
A:
var list:XMLList = xml.person;
var start:int = 10;
var end:int = 40;
var filteredList:XMLList = new XMLList();
for(i = start - 1; i < end; i++)
filteredList += new XML(XML(list[i]).toXMLString());
Amarghosh
2009-10-14 04:50:39
var filteredList:XMLList; should bevar filteredList:XMLList = new XMLList();
Eric Belair
2009-10-14 14:51:01
Oops, corrected. Thanks :)
Amarghosh
2009-10-14 14:53:09
Error: TypeError: Error #1086: The appendChild method only works on lists containing one item. Replacing the single expression in the for loop helped: var tempNode:XML = list[i]; filteredList += tempNode;
eterps
2009-10-15 00:22:34
Thanks for the correction - updated the code to fix it.
Amarghosh
2009-10-15 04:42:09
If you're converting the `list[i]` XML to String, then back to XML, only to create a copy of the XML object, you could just use list[i].copy();. I'm not sure why you're creating a copy though. simply doing `filteredList += list[i];` should work, right?
Niko Nyman
2009-12-07 22:04:09