python - 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
是不同的,在“办公室”和“桌子”
解决方案
推荐阅读
- error-handling - 当我的键是骡子中的动态时,如何从属性文件中获取值?
- javascript - RazorPay,我怎样才能获得付款失败的价值?
- javascript - Sequelize 和 Postgres - 无法实现外键约束“...”
- json - 如何从 Excel 中提取键值对并使用 Python 和/或在线转换器格式转换为 JSON
- docker-compose - 如何通过 docker 运行 gluu?我需要一个 docker-compose 示例
- windows - 查找多个文件并将它们复制到PowerShell中的另一个位置
- php - 根据当前日期计算日期范围
- java - W / System.err:java.io.IOException:无法运行程序“python”:错误= 13,权限被拒绝
- amazon-web-services - Elastic Beanstalk Worker 层构建失败并出现 SQSD 错误
- bash - How to `command file.txt OR another_file.txt` in CLI (bash/zsh)