特定の属性を持つ親ノードの子孫 (この場合は exchangeRate と PlacesOfInterest) を表示する方法を見つけようとしています。
シーンを設定するには - ユーザーは、文字列変数を目的地に設定するボタンをクリックします。日本かオーストラリア。
その後、コードは 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>