小编jcf*_*nco的帖子

使用ActionScript 3.0解析具有多个命名空间的XML Feed的推荐方法是什么?

我已经看到在几个在线示例中使用了以下方法,但没有找到有关解析XML提要的推荐方法的任何文档.

方法1:

protected function xmlResponseHandler(event:ResultEvent):void
{
    var atom:Namespace = new Namespace("http://www.w3.org/2005/Atom");
    var microsoftData:Namespace = new Namespace("http://schemas.microsoft.com/ado/2007/08/dataservices");
    var microsoftMetadata:Namespace = new   Namespace("http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");

    var ac:ArrayCollection = new ArrayCollection();
    var keyValuePairs:KeyValuePair;
    var propertyList:XMLList = (event.result as XML)..atom::entry.atom::content.microsoftMetadata::properties;

    for each (var properties:XML in propertyList)
    {
        keyValuePairs = new KeyValuePair(properties.microsoftData::FieldLocation, properties.microsoftData::Locationid);
        ac.addItem(keyValuePairs);     
    } 

    cb.dataProvider = ac;
}
Run Code Online (Sandbox Code Playgroud)

方法2:

protected function xmlResponseHandler(event:ResultEvent):void
{
    namespace atom = "http://www.w3.org/2005/Atom";
    namespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices";
    namespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";

    use namespace d;
    use namespace m;
    use namespace atom;

    var ac:ArrayCollection …
Run Code Online (Sandbox Code Playgroud)

xml parsing namespaces actionscript-3

7
推荐指数
1
解决办法
559
查看次数

标签 统计

actionscript-3 ×1

namespaces ×1

parsing ×1

xml ×1