我的功能是返回XML,所以我这样做:
返回xml.blah.blah.blah
它告诉我它无法将XMLList转换为XML
所以我猜xml.blah.blah.blah是一个XMLList。
我该怎么做(将XMLList转换为XML)?最简单的方法吗?
答案 0 :(得分:1)
您应该能够将XMLList转换为XML 之一:
XML(xml.blah.blah)
或
(xml.blah.blah as XML)
答案 1 :(得分:1)
您可以像访问数组一样访问XMLList的项目:
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);
}