【发布时间】:2011-11-28 19:54:48
【问题描述】:
我的 ElementTree 代码在 Python 2.7 中运行良好。 我需要在“X/Y”节点下获取所有名为“A”的节点。
from xml.etree.ElementTree import ElementTree
verboseNode = topNode.find("X/Y")
nodes = list(verboseNode.iter("A"))
但是,当我尝试使用 Python 2.6 运行它时,我收到了这个错误。
ionCalculateSkewConstraint.py", line 303, in getNodesWithAttribute
nodes = list(startNode.iter(nodeName))
AttributeError: _ElementInterface instance has no attribute 'iter'
看起来 Python 2.6 ElementTree 的节点没有 iter()。 如何使用 Python 2.6 实现 iter()?
【问题讨论】:
标签: python xml python-2.6 elementtree