草庐IT

xml - 如何使用 AS3 测试是否已在 XML 节点中设置属性

我正在读取AS3中的XML文件。我需要找出节点上是否存在属性。我想做类似的事情:if(xmlIn.attribute("id")){foo(xmlIn.attribute("id");//xmlInisoftypeXML}但这不起作用。上面的if语句总是为真,即使属性id不在节点上也是如此。 最佳答案 你必须这样做:if(xmlIn.hasOwnProperty("@id")){foo(xmlIn.attribute("id");//xmlInisoftypeXML}在XMLE4X解析中,您必须使用hasOwnProperty来检查