乌苏在线 立足乌苏 服务乌苏

attributes含义与用法详解
作者:佚名 www.ws10000.com 时间: 2007年11月14日
初次学习XML的朋友,可能对有些困惑,我本人当时就是。所以把自己的心得写出来,供初学者朋友参考。  下面我来看一下官方帮助文档对属于的定义:  一个对象,其中包含指定的 XML 实例的所有属性。XML.attributes 对象为 XML 实例的每个属性包含一个变量。因为这些变量定义为该对象的一部分,所以通常将它们称为该对象的属性。每个属性的值以字符串形式保存在相应的属性中。  下面,我们结合一个简单的XML文件来理解这段话,假设这段XML文件文件名为。  


  官方帮助文档中所谓的一个对象类似于自定义对象:Object,其中的属性值是可以自定义的,XML文档中的属性值就是以自定义对象的属性值保存在这个自定义对象中的。  为了便于理解,假设我们在Flash编写如下代码来解析这个XML文件。var wen:XML=new XML()wen.onLoad=function(){}wen.load("t.xml")其中大括号为详细的解析函数,我们暂时空出来,在后来详细解析。    这个对象就是wen.firstChild.firstChild.wen.firstChild对应XML中的部分为:node>
对应的部分是wen.firstChild.firstChild:  官方帮助文档中所谓的一个对象类在这里相当等价于wen.firstChild.firstChild。   我们再自定义一个这样的对象:var ma:Object=new Object() ma.namer="a1"ma.pic="02" ma.sm="btn1" ma.sn="m1" ma.link="http://www.aura.cn/TP/corp.asp"那么wen.firstChild.firstChild等价于自定义对象。 wen.firstChild.firstChild.attributes.namer 等于ma.namertrace(wen.firstChild.firstChild.attributes.namer ),将返回值a1   wen.firstChild.firstChild.attributes.pic等于 ma.pictrace(wen.firstChild.firstChild.attributes.pic)将返回值02   wen.firstChild.firstChild.attributes.等于smma.smtrace(wen.firstChild.firstChild.attributes.sm )将返回值btn1  wen.firstChild.firstChild.attributes.sn等于ma.sntrace(wen.firstChild.firstChild.attributes.sm )将返回值m1    wen.firstChild.firstChild.attributes.link等于ma.linktrace(wen.firstChild.firstChild.attributes.link )将返回值http://www.aura.cn/TP/corp.asp attributes属性值与XML文件中的属性值的对应相系大概就是这样的,初学者朋友参考此例举一反三相信能够很容易理解属性的attributes含义和用法。点此在新窗口浏览<a href=图片" onclick="javascript:window.open(this.src);" onmousewheel="return bbimg(this)" onload="javascript:resizepic(this)" border="0"/> []

人支持
【当前文章】URL:/Html/JSXX/TT/441761115938.html
发表评论】【告诉好友】【打印此文】【收藏此文】【关闭窗口

热门信息

推荐信息

版权所有:飞扬科技 未经授权不得转抄本站原创资源或建立镜像
国家信息产业部备案号: 新ICP备07000481号
Copyright ◎ 2005-2008 www.ws10000.com Online Services. All Rights Reserved