【问题标题】:AS3 XML, nodeName with attributes comes up blankAS3 XML,带有属性的 nodeName 出现空白
【发布时间】:2010-01-11 20:49:59
【问题描述】:

我尝试了许多不同的方法来访问属性的名称,但就是无法正常工作。

当前函数:

protected function applyProperties(_axml:XML):void
{
    var list:XMLList = _axml.properties;
    var list2:XMLList = list.attributes();

    for (var i = 0; i < list2.length(); i++) {
        trace(list2[i].nodeName.toString());
    }
}

它所指的 XML:

<content type="media">
<target>warning.png</target>
<properties x="20" mouseEnabled="$false"></properties>
</content>

我试过这个名字,我试过将它作为一个对象搜索,我在 stackoverflow 上寻找解决方案。到目前为止,没有什么对我有用。最初我有这样的属性节点: 担心 Flash 解释不正确。

编辑:似乎 XML 被解释而不是打印出来..

【问题讨论】:

    标签: xml actionscript-3 flash


    【解决方案1】:

    list2[i] 将是一个 XML 对象。

    XML 对象没有 nodeName,这是一个 XMLNode 对象。

    试试

    list2[i].name().toString();
    

    【讨论】:

      【解决方案2】:

      我的一个项目需要这个,这段代码很有魅力:

      for (var u:uint=0; u<myXMLList[i].attributes().length(); u++){
                     LevelOne::DataXML.questionset..q[i].@[myXMLList[i].attributes()[u].name().toString()] = myXMLList[i].attributes()[u];
                     LevelTwo::DataXML.questionset..q[i].@[myXMLList[i].attributes()[u].name().toString()] = myXMLList[i].attributes()[u];
                     LevelThree::DataXML.questionset..q[i].@[myXMLList[i].attributes()[u].name().toString()] = myXMLList[i].attributes()[u];
                  }
      

      感谢WORMSS!

      【讨论】:

        猜你喜欢
        • 2012-03-24
        • 1970-01-01
        • 1970-01-01
        • 2013-08-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-09-13
        • 1970-01-01
        相关资源
        最近更新 更多