After
I have XML
which is 6042 lines of data.
I am doing the parsing with the following code,
import urllib2 import as the print, lxml.etree 'execution started here' url = "url here Goes "xmldata = urllib2.urlopen (url) .read () root = ET.fromstring (xmldata) Print 'Done' print root for Xin in root: print xin.tag, xin.attrib
Sometimes it runs successfully, but sometimes it finds the following errors,
1 lxml.etree.XMLSyntaxError: Opening and closing tag mismatch: ClinicID line 54 and Location, line 54, column 60016 2. httplib.IncompleteRead: IncompleteRead (read 964 bytes)
1 explanation for error: I downloaded my xml
on this application Is copied and does not show any errors in it clearly it shows that XML
is completely free error.
So what am I doing here?
Any help would be appreciated.
Here's my XML format
& lt; Places & gt; & Lt; Location & gt; & Lt; LocationID & gt; & Lt; / LocationID & gt; & Lt; ClinicID & gt; 111 & lt; / ClinicID & gt; & Lt; Building Type & gt; A type & lt; / Building type & gt; & Lt; Address & gt; Address & lt; / Address & gt; & Lt; Addresses 2 & gt; & Gt; Address 1 & lt; / Address2 & gt; & Lt; City & gt; City 1 & lt; / City & gt; & Lt; State & gt; State 1 & lt; / State & gt; & Lt; Zip & gt; ZIP 1 & lt; / Zip & gt; & Lt; / Location & gt; & Lt; Location & gt; & Lt; LocationID & gt; & Lt; / LocationID & gt; & Lt; ClinicID & gt; 111 & lt; / ClinicID & gt; & Lt; Building Type & gt; A type & lt; / Building type & gt; & Lt; Address & gt; & Gt; Address & lt; / Address & gt; & Lt; Address2 & gt; & Gt; Address & lt; / Address2 & gt; & Lt; City & gt; City 1 & lt; / City & gt; & Lt; State & gt; State 1 & lt; / State & gt; & Lt; Zip & gt; ZIP 1 & lt; / Zip & gt; & Lt; / Location & gt; . . . . . . & Lt; Location & gt; & Lt; LocationID & gt; & Lt; / LocationID & gt; & Lt; ClinicID & gt; 111 & lt; / ClinicID & gt; & Lt; Building Type & gt; A type & lt; / Building type & gt; & Lt; Address & gt; & Gt; Address & lt; / Address & gt; & Lt; Address2 & gt; & Gt; Address & lt; / Address2 & gt; & Lt; City & gt; City 1 & lt; / City & gt; & Lt; State & gt; State 1 & lt; / State & gt; & Lt; Zip & gt; ZIP 1 & lt; / Zip & gt; & Lt; / Location & gt; & Lt; / Places & gt;
Update
I have downloaded the xml file and have tried to open it locally. It's working without any errors, then why is not it working with urllib2.urlopen (url) .read ()? Any limitations?
Comments
Post a Comment