【问题标题】:Actionscript 3 - How can i convert from XMLList to XML?Actionscript 3 - 如何从 XMLList 转换为 XML?
【发布时间】:2012-01-17 12:16:40
【问题描述】:

我的函数正在返回 XML,所以我这样做了:

返回 xml.blah.blah.blah

它告诉我它不能将 XMLList 转换为 XML

所以我猜 xml.blah.blah.blah 是一个 XMLList。

我该怎么做(将 XMLList 转换为 XML)?最简单的方法?

【问题讨论】:

    标签: actionscript-3 flash-builder flash-cs5 flash-cs4


    【解决方案1】:

    您应该能够将 XMLList 转换为 XML。
    要么:

    XML(xml.blah.blah)
    

    或

    (xml.blah.blah as XML)
    

    【讨论】:

    • 你是对的,我没有注意到 xml.blah.blah.blah 之前的 XML 抱歉,我已经将你的答案标记为正确。非常感谢:D
    【解决方案2】:

    您可以像访问数组一样访问 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);
    }
    

    【讨论】:

      猜你喜欢
      • 2013-03-30
      • 2011-07-02
      • 1970-01-01
      • 1970-01-01
      • 2017-12-24
      • 2017-08-03
      • 2019-08-11
      • 2011-06-05
      • 1970-01-01
      相关资源
      最近更新 更多