Reputation: 1101
Here's the Python source:
fsock = urllib2.urlopen('http://eprints.soton.ac.uk/cgi/exportview/divisions/uos-fp/2009/XML/uos-fp_2009.xml')
doc=et.parse(fsock)
When I tried to run this it gives the following error:
Traceback (most recent call last): File "C:\Python27\reading and writing xml file from web1.py", line 30, in doc=et.parse(fsock) File "C:\Python27\lib\xml\etree\ElementTree.py", line 1176, in parse tree.parse(source, parser) File "C:\Python27\lib\xml\etree\ElementTree.py", line 654, in parse self._root = parser.close() File "C:\Python27\lib\xml\etree\ElementTree.py", line 1635, in close self._raiseerror(v) File "C:\Python27\lib\xml\etree\ElementTree.py", line 1487, in _raiseerror raise err ParseError: no element found: line 1, column 0
Can any one help as to why this is happening?
Upvotes: 1
Views: 5862
Reputation: 3609
Your code works:
import urllib2
from xml.etree.cElementTree import parse, dump
fsock = urllib2.urlopen('http://eprints.soton.ac.uk/cgi/exportview/divisions/uos-fp/2009/XML/uos-fp_2009.xml')
doc = parse(fsock)
dump(doc)
Upvotes: 0