0

I have something like this

for country in root.findall('{urn:oasis:names:tc:opendocument:xmlns:office:1.0}body/{urn:oasis:names:tc:opendocument:xmlns:office:1.0}text/{urn:oasis:names:tc:opendocument:xmlns:table:1.0}table/{urn:oasis:names:tc:opendocument:xmlns:table:1.0}table-row/{urn:oasis:names:tc:opendocument:xmlns:table:1.0}table-cell'):

How can I shorten it?

{urn:oasis:names:tc:opendocument:xmlns:office:1.0}body

and

{urn:oasis:names:tc:opendocument:xmlns:table:1.0}table-cell

are different, at "office" and "table"

mzjn
  • 48,958
  • 13
  • 128
  • 248
lars
  • 1
  • https://stackoverflow.com/a/14853417/5386938 –  Jan 27 '21 at 13:49
  • Does this answer your question? [Parsing XML with namespace in Python via 'ElementTree'](https://stackoverflow.com/questions/14853243/parsing-xml-with-namespace-in-python-via-elementtree) –  Jan 27 '21 at 13:50
  • 1
    With Python 3.8 and later, you can use a wildcard: https://stackoverflow.com/a/62117710/407651. – mzjn Jan 27 '21 at 14:00
  • 1
    yeah, that works @mzjn .//{*} – lars Jan 27 '21 at 19:32

0 Answers0