【发布时间】:2013-03-27 23:52:50
【问题描述】:
我有一个元素 submission_ref 与文本内容 123 我正在解析如下:
xml = request.POST['xml'].encode('utf-8')
parser = etree.XMLParser(ns_clean=True, recover=True, encoding='utf-8')
h = fromstring(xml, parser=parser)
submission_ref = h.xpath('submission_ref/text()');
我的问题是我不能使用变量submission_ref 中的值,因为它看起来像这样:['123'] 被解析后。查看额外的[' 和']。
这和xpath() 有关系吗?我该如何解决这个问题?
【问题讨论】:
-
请不要在 Python 中使用分号,它们不是必需的。
-
哈巴特之力。哎呀
标签: python django xml-parsing lxml