使用python进行Xml解析

时间:2014-02-19 11:11:11

标签: python xml parsing xml-parsing elementtree

我使用xml使用python解析xmltodict。但我得到了以下错误,

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

这是我的代码,

import xmltodict
import urllib2
url="url here"
data=xmltodict.parse(urllib2.urlopen(url).read())
print data

我也尝试过使用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所有节点?

0 个答案:

没有答案