基于python的Xml解析

2024-04-25 16:32:13 发布

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

我正在用python使用xmltodict解析xml。但我犯了以下错误

xml.parsers.expat.ExpatError: mismatched tag: line 2890, column 2

这是我的密码

^{pr2}$

我也尝试过使用etree

这是密码

import urllib2
import lxml.etree as ET
print 'Started Execution here'
url="url here"
xmldata = urllib2.urlopen(url).read()
root = ET.fromstring(xmldata)
print 'Done'
print root

这也给了我错误

lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: ClinicID line 54 and Type, line 55, column 14

我知道xml有问题。
我的问题是,有没有任何方法可以读取xml中除了引起错误的节点之外的所有节点?在


Tags: importurl密码heretag错误linecolumn