如何解决无效的属性名称错误? (可能的原因是属性名称中的冒号)

时间:2019-04-03 11:20:41

标签: python xml python-3.x attributes lxml

这是实际的代码:

from lxml import etree
root = etree.Element("doi_batch", attrib={
               'xmlns': "http://www.crossref.org/schema/4.4.0", 
               'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', 
               "version": "4.4.0", 
               "xsi:schemaLocation": "http://www.crossref.org/schema/4.4.0 http://www.crossref.org/schema/deposit/crossref4.4.0.xsd"
               })
print(etree.tostring(root, encoding="UTF-8", 
                     method="xml", xml_declaration=True, pretty_print=True))

问题是某些属性的名称中必须包含冒号,因此输出错误。 这类错误有解决方案吗?

输出:

enter image description here

0 个答案:

没有答案
相关问题