0

私はこれを何度も行ってきましたが、今は何かが欠けています.... 属性の値を探してノードを探しています。

トレースしようとすると:

 xmlQuestStructure.page[activePageIndex].label.@priority

トレースは問題ありません。High、Medium、Low (予想される値) を読み取ることができます。

しかし、これをトレースしようとすると (ここで、calculatedPriority は値が High、Medium、または Low の文字列です)

 xmlQuestStructure.page[activePageIndex].label.(@priority == calculatedPriority)

ReferenceError: エラー #1065: 変数の優先度が定義されていません

私は何を間違っていますか?助けてくれてありがとう!

4

1 に答える 1

1

Most likely, your problem is that one of your label nodes DOESN'T have a priority attribute defined. When you use @ in e4x, it will throw an error if it comes to a XML node that doesn't have the attribute specified.

If there is a possibility that your XMLnode could have the attribute omitted, then instead of using '@', use attribute().

So in your case, you could do this:

xmlQuestStructure.page[activePageIndex].label.(attribute("priority") == calculatedPriority);

using attribute() is more passive, and will ignore the node if it doesn't have the specified attribute, instead of throwing an error.

于 2012-09-25T17:41:47.787 に答える