通过flash调用XML中的特定项

时间:2011-03-03 15:44:14

标签: xml flash actionscript-3

我想知道如何通过flash调用xml中的特定项目? 这是我的XML

<menu>
<day>
    <monday>            
        <maindish>
        <name>Curry Goat</name>
            <small>$6.86</small>
            <large>$9.00</large>
            </maindish>
    </monday>
    <tuesday>            
        <maindish>
        <name>Curry Goat</name>
            <small>$6.86</small>
            <large>$9.00</large>
            </maindish>
    </tuesday>
    <wednesday>            
        <maindish>
        <name>Curry Goat</name>
            <small>$6.86</small>
            <large>$9.00</large>
            </maindish>
    </wednesday>
</day>

这是Flash中的代码

for each (var maindish:XML in myXML..maindish)

如何加载特定日期的信息,假设是否选择了星期三。

1 个答案:

答案 0 :(得分:0)

 Is this what you are looking for?

 var menueXml:XML = <menu>  
 <day>      
 <monday>
 <maindish>         
 <name>Curry Goat</name>
 <small>$6.86</small>              
 <large>$9.00</large>
 </maindish>     
 </monday>      
 <tuesday>
 <maindish>
 <name>Curry Goat</name>
 <small>$6.86</small> 
 <large>$9.00</large>
 </maindish>      
 </tuesday>      
 <wednesday>
 <maindish>
 <name>Curry Goat</name>
 <small>$6.86</small>
 <large>$9.00</large> 
 </maindish>
 </wednesday>
 </day>
 </menu>;

 for each(var main in menueXml.day){
 trace(main.monday.maindish.name.text());
 trace(main.monday.maindish.small.text());
 trace(main.monday.maindish.large.text());
 trace(main.tuesday.maindish);
 trace(main.wednesday.maindish);
 }