actionscript 2.0读取XML文件
我正在尝试使用actionscript 2.0读取XML文件 问题是我只能让代码通过引用标记的位置来读取标记的值 e、 g。actionscript 2.0读取XML文件,xml,actionscript,Xml,Actionscript,我正在尝试使用actionscript 2.0读取XML文件 问题是我只能让代码通过引用标记的位置来读取标记的值 e、 g。 var currentIcon=myXML.firstChild.firstChild.childNodes[0].firstChild 如何通过引用XMl文件的标记名从XMl文件中检索值 e、 g。 var currentIcon=myXML.firstChild.firstChild.childNodes['icon'].firstChild 这是我的XML文件 &l
var currentIcon=myXML.firstChild.firstChild.childNodes[0].firstChild代码>
如何通过引用XMl文件的标记名从XMl文件中检索值
e、 g。
var currentIcon=myXML.firstChild.firstChild.childNodes['icon'].firstChild代码>
这是我的XML文件
<weather>
<current>
<icon>Partly cloudy</icon>
<temphigh>33</temphigh>
<templow>24</templow>
<humhigh>55</humhigh>
<humlow>95</humlow>
</current>
<forecast1>
<day>Monday</day>
<icon>rss_ts2</icon>
<temphigh>33</temphigh>
<templow>24</templow>
</forecast1>
<forecast2>
<day>Tuesday</day>
<icon>rss_ts2</icon>
<temphigh>32</temphigh>
<templow>23</templow>
</forecast2>
<forecast3>
<day>Wednesday</day>
<icon>rss_ts2</icon>
<temphigh>32</temphigh>
<templow>23</templow>
</forecast3>
</weather>
多云
33
24
55
95
星期一
rss_ts2
33
24
星期二
rss_ts2
32
23
星期三
rss_ts2
32
23
在AS2中,您不能直接从子节点
数组中按名称检索节点(您可以在AS3中使用E4X和点表示法进行检索)。您应该使用XML2Object
解析器将加载的XML
转换为本机AS2对象,如下所示:
然后您将使用点符号访问您的XML
,如weather.current.icon
该链接包含XML2Object
AS2类和一些示例
此链接解释了在AS2和AS3中如何处理XML文档的区别: