Following is my xml file contents,
1
ElementTree only supports a subset of XPath 1.0. See https://docs.python.org/2/library/xml.etree.elementtree.html#xpath-support. Functions such as not()
or count()
do not work.
Here is how you can select neighbor
elements that don't have a direction
attribute without using XPath:
tree = ET.parse(fileName)
for n in tree.iter('neighbor'):
if not(n.get('direction')): # If the element has no 'direction' attribute...
print n.get('name') # then print the value of the 'name' attribute