0
嘗試構建xml並注入包含許多元素的字符串。但是,通過做下面的錯誤,並不知道什麼是錯的。將XML內容注入標記時出現Python錯誤
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
蟒(2.7.10) LXML(3.7.3)
感謝現在的工作! – bogumbiker