【发布时间】:2014-08-18 09:35:31
【问题描述】:
在 Python 的 lxml.etree 中,如何将命名空间添加到像这样的节点的属性中: 命名空间是:
XS_NS = 'http://www.w3.org/2001/XMLSchema'
寻找的结果是:
<xs:element name="label" type="xs:string"></xs:element>
我试过这个,但结果不是我想要的:
element = ET.SubElement(
sequence,
ET.QName(XS_NS, "element"),
name="label",
type=str(ET.QName(XS_NS, "string")),
)
给我:
<xs:element name="label" type="{http://www.w3.org/2001/XMLSchema}string"/>
【问题讨论】:
标签: python xml elementtree