代码之家  ›  专栏  ›  技术社区  ›  invertedSpear

为什么会收到这样的警告:3594:父级不是动态类XML的可识别方法?

  •  0
  • invertedSpear  · 技术社区  · 15 年前

    它来自这一行代码:

    var dropTargetXML:XML = XMLTemplate.template.component.section.question.(@question_questionID == nNode.parent().@question_questionID)[0];
    

    node是一个XML节点,作为参数发送到调用它的函数。代码运行,并执行除编译器发出警告之外的所有预期操作。我有格式问题吗?

    另外,我试着告诉它它是这样的XML:

    var dropTargetXML:XML = XMLTemplate.template.component.section.question.(@question_questionID == XML(nNode).parent().@question_questionID)[0];
    

    但我还是得到了警告。

    1 回复  |  直到 15 年前
        1
  •  2
  •   Robert Bak    15 年前

    我不知道它实际上是如何实现的,但我猜XML过滤中的某些东西会在幕后对它起作用。一个快速的解决方案是将有问题的代码从过滤范围中拉出,例如:

    var questionIDToFind:String = nNode.parent().@question_questionID;
    XMLTemplate.template.component.section.question.(@question_questionID == questionIDToFind)[0];
    

    如果你好奇的话,你可以在第62-63页的 ECMAScript for XML (E4X) Specification