find
and findall
only implement a subset of XPath. Their presence is meant to provide compatibility with other ElementTree implementations (like ElementTree
and cElementTree
).
The xpath
method, in contrast, provides full access to XPath 1.0:
print customer.xpath('./@NAME')[0]
However, you could instead use get
:
print customer.get('NAME')
or attrib
:
print customer.attrib['NAME']