我一直在想出如何显示具有特定属性的父节点的后代(在本例中为exchangeRate和PlacesOfInterest)。如何在AS3中显示具有特定属性的节点的XML后代?
要设置场景 - 用户单击一个按钮,将字符串变量设置为目标,例如。日本或澳大利亚。
的代码,然后通过在XML节点组和任何具有匹配属性被跟踪运行 - 非常简单
我想不通的是如何则仅显示的子节点具有该属性的节点。
我确信必须有这样做的方式,我可能会在我找到它时将头撞到桌子上,但任何帮助都将不胜感激!
public function ParseDestinations(destinationInput:XML):void
{
var destAttributes:XMLList = destinationInput.adventure.destination.attributes();
for each (var destLocation:XML in destAttributes)
{
if (destLocation == destName){
trace(destLocation);
trace(destinationInput.adventure.destination.exchangeRate.text());
}
}
}
<destinations>
<adventure>
<destination location="japan">
<exchangeRate>400</exchangeRate>
<placesOfInterest>Samurai History</placesOfInterest>
</destination>
<destination location="australia">
<exchangeRate>140</exchangeRate>
<placesOfInterest>Surf and BBQ</placesOfInterest>
</destination>
</adventure>
</destinations>
三江源乔治!这帮了我很多!我知道必须有一个简单的方法 - 现在我肯定会阅读这些帖子 – 2011-02-22 17:20:44