如何使用python请求将xml作为html打开

2024-10-04 09:28:23 发布

您现在位置:Python中文网/ 问答频道 /正文

嘿,伙计们,能帮帮我吗?我想用python请求打开xml。我想在html站点中打开某些行。我的xml的名称是out.xml 这是我的实际代码:

import lxml.html.builder as html
from lxml import etree

nodeTable=html.BODY(html.TABLE)
for i in range(0, 20 ):
    nodeRow=html.TR(html.TD("user", style="background-color:#FF0000"), html.TD("blabla"), html.TD("zweite zeile"))
    nodeTable.append(nodeRow)


print etree.tostring(nodeTable)
with open("out.html", "wb") as f:
    f.write(etree.tostring(nodeTable))

很明显,我不想有“第一排”和“第二排”。在这个职位上,我希望有自己的xml结果。我感谢你的帮助:)


Tags: import名称站点htmlasxmloutlxml