Reputation: 115
My function is returning XML, so i do:
return xml.blah.blah.blah
It tells me it can't convert XMLList to XML
so i'm guessing xml.blah.blah.blah is a XMLList.
How can i do this (convert XMLList to XML)? the simpliest way possible?
Upvotes: 1
Views: 3563
Reputation: 1261
You can access items of an XMLList like you would an array:
var booksXML:XML =
<Books>
<Book ISBN="0000000000">
<title>Title 1</title>
<author>Author 1</author>
</Book>
<Book ISBN="1111111111">
<title>Title 2</title>
<author>Author 2</author>
</Book>
<Book ISBN="2222222222">
<title>Title 3</title>
<author>Author 3</author>
</Book>
<Book ISBN="3333333333">
<title>Title 4</title>
<author>Author 4</author>
</Book>
</Books>;
var authorList:XMLList = booksXML.Book.author;
for (var i:int = 0; i < authorList.length(); i++)
{
var authorElement:XML = authorList[i];
trace(authorElement);
}
Upvotes: 1
Reputation: 4629
You should be able to just cast the XMLList to XML.
Either:
XML(xml.blah.blah)
or
(xml.blah.blah as XML)
Upvotes: 1