这是实际的代码:
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))
问题是某些属性的名称中必须包含冒号,因此输出错误。 这类错误有解决方案吗?
输出: