Get Flex XML attribute name
来源:互联网 发布:java开发数据库面试题 编辑:程序博客网 时间:2024/06/08 09:14
Theattributes()method returns anXMLListobject with all the data from the attributes contained within anXMLobject. You can call thename()method for each attribute in theXMLListto retrieve the name of the attribute as a string. You can then use that value as a parameter, which you can pass to theattribute()method of theXMLobject to retrieve the value of the attribute. The following example illustrates how this works:
var author0:XML = xml.children()[0].children()[1].children()[0];
var attributes:XMLList = author0.attributes();
var attributeName:String;
for(var i:uint = 0; i < attributes.length(); i++) {
attributeName = attributes[i].name();
trace(attributeName + " " + author0.attribute(attributeName));
}
Asyou can see, traversing the XML DOM is effective but laborious. Often,it’s far more effective to use E4X syntax, particularly when youalready know the structure. E4X syntax allows you to access child nodesby name as properties of parent nodes. For example, the followingaccesses the first book node:
trace(xml.book[0]);
Youcan chain together this simple E4X syntax as in the following example,which retrieves the first author node of the first book node:
trace(xml.book[0].authors.author[0].toXMLString());
E4X also allows you to easily access attributes using the@ symbol. The following uses this syntax to retrieve the value of the first attribute of the author node:
trace(xml.book[0].authors.author[0].@first);
Youcan also use E4X filters. Filters are enclosed in parentheses withinwhich you specify conditions. The following example retrieves all theauthor nodes in which the last attribute isKazoun:
var authors:XMLList = xml.book.authors.author.(@last == "Kazoun");
for(var i:uint = 0; i < authors.length(); i++) {
trace(authors[i].parent().parent().toXMLString());
}
- Get Flex XML attribute name
- applicationContext.xml文件中的异常: Attribute : name The name of the property, following JavaBean naming c
- Undefined attribute name (xmlns)
- 55. Attribute name 属性
- 在applicationContext.xml中配置Service层时 name Tag ‘property’ must have a ‘name’ attribute 出错的问题
- struts-config.xml中 action 的attribute属性与name属性
- struts-config.xml中action配置 --> attribute和name的区别
- struts-config.xml中action配置--> attribute和name的区别(转)
- struts-config.xml中 action 的attribute属性与name属性
- XML(2) Attribute
- Set And Get Attribute --- DOS
- Get Dir Path Name
- EVIOCGNAME:Get Device Name
- EVIOCGNAME:Get Device Name
- get file name
- Magento: Get category name
- EVIOCGNAME:Get Device Name
- get pid by name
- CentOS 下的 Apache CA 证书申请与导入日志
- 一些数据结构的内存和时间比较
- SkyEye硬件模拟平台:硬件仿真实现之五
- [max-flow]ford-fulkerson algorithm (转)
- 布局
- Get Flex XML attribute name
- Webbrowser 获取验证码显示在图片框中
- 如何在三个月掌握三年的经验
- 中图法分类号(计算机专业)
- 我所理解的归并排序算法
- Velocity java开发指南
- SkyEye硬件模拟平台:硬件仿真实现之六
- CRF的内存使用情况
- 发现了一个好咚咚,swflib,可以像写c程序那样做出swf来