如何从XML中的Flex /动作脚本检索节点名 [英] How do I retrieve the node name from XML in Flex / Actionscript

查看:100
本文介绍了如何从XML中的Flex /动作脚本检索节点名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些看起来像这样的数据的XML数据

I have some data xml data that looks like this

<root xsi:noNamespaceSchemaLocation="test1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <configuration>
    <CLICK/>
    <KLT/>
    <DETd/>
  </configuration>
</root>

我得到使用配置的列表

I get a list of the configurations using

VAR结果:返回XMLList = xml.configuration *;

var results:XMLList = xml.configuration.*;

现在我想遍历XMLList并输出CLICK,康莱特,DETd等,但如何在XML中我得到的节点名,例如

Now I want to loop over the XMLList and output CLICK, KLT, DETd etc. but how in XML do I get the node name as such

推荐答案

XML:

<root>
    <parentNode>
        <childNode1>1</childNode1>
        <childNode2>2</childNode2>
        <childNode3>3</childNode3>
    </parentNode>
</root>

所有你需要做的是使用。名称()同时通过 parentNode 的迭代儿童()

All you need to do is use .name() while iterating through parentNode's children().

for(var i:int=0;i<xml.children()[0].children().length();i++)
{
    var currentNode:XML = xml.children()[0].children()[i];
    trace(currentNode.name());
}

//childNode1
//childNode2
//childNode3

更多:

  1. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XMLList.html
  2. http://help.adobe.com/en_US/ FlashPlatform /参考/动作/ 3 / XML.html
  1. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XMLList.html
  2. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XML.html

这篇关于如何从XML中的Flex /动作脚本检索节点名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆