nmduc073 posted on June 01, 2009 06:10::119 view(s)
Mình có đoạn code sau đây từ file xml. Nó chứa thông tin các menu item.
<menuitems>
<menuitem label="L1" data="L1">
<menuitemchild label="L11" data="L11" link="test.html"/>
<menuitemchild label="L12" data="L12" link="test.html"/>
</menuitem>
<menuitem label="L2" data="L2">
<menuitemchild label="L21" data="Duc L21" link="accordionmenuex.html" />
<menuitemchild label="L22" data="Nguyen L22" link="test.html" />
</menuitem>
</menuitems>
Và dưới đây là code để duyệt tất cả để lấy thông tin.
privatefunction init():void
{
nuVbox=menuBarXML.length();
if(nuVbox>0)
{
var i:int=0;
var item:XML;
foreach(item in menuBarXML)
{
var myVbox:VBox= new VBox();
myVbox.label=item.@label;
myVbox.id=item.@label;
myVbox.width=this.width;
this.addChild(myVbox);
var temp:XMLList;
var item1:XML;
temp=item.descendants("menuitemchild");
//Alert.show(temp.toXMLString()+"|"+temp.@label);
foreach (item1 in temp)
{
//Alert.show(item1.toXMLString()+"|"+item1.@label);
}
}
}
}
[Read the rest of this article...]