的ReferenceError:错误#1065:寻找一个节点,通过属性时,变量没有定义 [英] ReferenceError: Error #1065: Variable is not defined when searching for a node by attribute

查看:257
本文介绍了的ReferenceError:错误#1065:寻找一个节点,通过属性时,变量没有定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这样做很多次了,但现在我想的东西.... 我通过寻找一个属性的值寻找一个节点。

I've done this lot of times, but now I'm missing something.... I'm searching for a node by looking for a value in an attribute.

如果我尝试跟踪:

 xmlQuestStructure.page[activePageIndex].label.@priority

跟踪它的确定,我可以读高,中,低(该值我很期待)。

The trace it's ok, and I can read High, Medium, Low (the values I'm expecting).

但是,如果我尝试跟踪该(其中calculatedPriority是价值高,中,低字符串)

But if I try to trace this (where calculatedPriority is a String with value High, Medium or Low)

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

我得到的ReferenceError:错误#1065:变量的优先级没有定义

I get ReferenceError: Error #1065: Variable priority is not defined

我是什么做错了吗? THX您的帮助!

What am I doing wrong? Thx for your help!

推荐答案

最有可能的,你的问题是,你的标签节点之一的有一个优先级属性定义。当您使用 @ 在E4X,它会如果涉及到不具有的属性指定的XML节点抛出一个错误。

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.

如果有可能,你的XmlNode的本来属性被忽略,那么而是采用'@',用属性()

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.

这篇关于的ReferenceError:错误#1065:寻找一个节点,通过属性时,变量没有定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆