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?
Asked
Active
Viewed 389 times
1 Answers
1
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
- 58,710
- 11
- 92
- 121
-
1var filteredList:XMLList; should be var filteredList:XMLList = new XMLList(); – Eric Belair Oct 14 '09 at 14:51
-
1Error: 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 Oct 15 '09 at 00:22
-
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 Dec 07 '09 at 22:04