这是一个更大的XML的一小部分:
<menu first="modelID">
<model>
<id>modelID</id>
<nome>Name</nome>
<cover type="img">./img/cover.png</cover>
<sub value="Images|Audio" />
</model>
<model>
<id>modelID2</id>
...
</model>
使用E4X我轻松从菜单“first”属性中检索值,然后将其保存到变量( firstModel )。
现在我想要检索 id 等于 firstModel <的节点的封面类型和封面文字() / strong>即可。我能怎么做?这可能吗?
答案 0 :(得分:2)
var firstModel : String = "modelID"; //your parsed value here
trace(a.model.(id == firstModel).cover.@type);
trace(a.model.(id == firstModel).cover);
输出:
[trace] img
[trace] ./img/cover.png