Skip to content Skip to sidebar Skip to footer

Lxml Attributes Require Full Namespace

The code below reads the a table from an Excel 2003 XML workbook using lxml (python 3.3). The code works fine, however in order to access the Type attribute of the Data element via

Solution 1:

According to The lxml.etree Tutorial -- Namespace:

The ElementTree API avoids namespace prefixes wherever possible and deploys the real namespaces (the URI) instead:


BTW, following

cell.get('{urn:schemas-microsoft-com:office:spreadsheet}Type')

can be written as:

cell.get('{%(ss)s}Type' % namespaces)

or:

cell.get('{{{0[ss]}}}Type'.format(namespaces))

Post a Comment for "Lxml Attributes Require Full Namespace"