【发布时间】:2021-10-10 07:18:46
【问题描述】:
我正在尝试修改 XML 并将输出写入output.xml,但我没有得到所需的输出。在我的 XML 中,我们有不同的命名空间:
- 根命名空间
- 子命名空间
我可以使用register_namespace 保留根命名空间,但我无法为<genericSelection> PSB 保留子命名空间。
有人可以帮助我实现它。
原始文件sn-p:
<ptc:PricingObjectsJXB xmlns:ptc="http://xmlns.xyz.com/comm/platform/model">
<genericSelection xmlns:ptc="http://xmlns.xyz.com/comm/platform/model"></genericSelection>
</ptc:PricingObjectsJXB>
输出文件sn-p:
<ptc:PricingObjectsJXB xmlns:ptc="http://xmlns.xyz.com/comm/platform/model">
<genericSelection> missing namespace here</genericSelection>
</ptc:PricingObjectsJXB>
提前致谢。
【问题讨论】:
标签: python-3.x xml elementtree xml.etree