xml parsing in python

noaptus

New Member
my xml code fetched over network looks like this \[code\]<?xml version='1.0' ?><liverequestresponse><liverequesttime>180</liverequesttime><livemessage></livemessage></liverequestresponse>\[/code\]and my python minidom code is\[code\]import urllib, urllib2, timefrom xml.dom.minidom import parseresponse = urllib2.urlopen(req)the_page = response.read() #print the_page dom = parse(response)name = dom.getElementsByTagNameNS('liverequestresponse')print name[0].nodeValue\[/code\]gives some errors\[code\]print the_page\[/code\]works fineOr if they are any other libraries which are better than minidom, plz tell me..I would prefer the one which comes pre-installed on linuxUPDATEerrors\[code\]Traceback (most recent call last): File "logout.py", line 18, in <module> dom = parse(response) File "/usr/lib64/python2.7/xml/dom/minidom.py", line 1920, in parse return expatbuilder.parse(file) File "/usr/lib64/python2.7/xml/dom/expatbuilder.py", line 928, in parse result = builder.parseFile(file) File "/usr/lib64/python2.7/xml/dom/expatbuilder.py", line 211, in parseFile parser.Parse("", True)xml.parsers.expat.ExpatError: no element found: line 1, column 0\[/code\]
 
Back
Top