首页 > 解决方案 > python, xml.etree, 使用命名空间解析 XML

问题描述

我有这样的东西

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'):

我怎样才能缩短它?

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

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

是不同的,在“办公室”和“桌子”

标签: pythonxmlelementtreexml-namespaces

解决方案


推荐阅读