尝试构建xml并注入包含许多元素的字符串。但是通过以下方式获取错误并且不确定是什么问题。
from lxml import etree
from lxml.builder import E as e
list = ["one", "two", "three", "four", "five"]
fields = "".join("<field>{}</field>".format(x) for x in list)
xml = page = (
e.req(
e.tab(
e.fields(
etree.fromstring(fields)
)
)
)
)
错误:
lxml.etree.XMLSyntaxError: Extra content at the end of the document, line 1, column 20
python(2.7.10) lxml(3.7.3)