[Expat-discuss] File not found error in the parser
Justin Seyster
jseyster at cs.stonybrook.edu
Wed Jun 30 01:16:14 CEST 2010
Hmm, I wrote a script that just opens and parses an XML file, and it
gives me the same problem. It looks like it's definitely something
wrong either with my machine's configuration or the particular version
of Python (and its Expat wappers) that I'm using.
I put the script below.
--Justin
#!/usr/bin/env python
import sys
from xml.sax import handler
from xml.sax import make_parser
from xml.sax.handler import feature_namespaces
class BlankHandler(handler.ContentHandler):
def __init__(self):
pass
def startElement(self, name, attrs):
print "Start: ", name
pass
def endElement(self, name):
print "End: ", name
pass
if __name__ == '__main__':
if len(sys.argv) != 2:
sys.exit(1)
xmlfile = sys.argv[1]
parser = make_parser()
parser.setFeature(feature_namespaces, 0)
dh = BlankHandler()
parser.setContentHandler(dh)
try:
xmlhandle = open(xmlfile, 'r')
# Uncommenting the line below shows that xmlhandle can be read
# successfully.
#print xmlhandle.readline()
parser.parse(xmlhandle)
xmlhandle.close()
except IOError as e:
print "IOError: ",
print e.strerror
sys.exit(1)
On Tue, 2010-06-29 at 18:43 -0400, Fred Drake wrote:
> On Tue, Jun 29, 2010 at 6:27 PM, Justin Seyster
> <jseyster at cs.stonybrook.edu> wrote:
> > The one directory that works is not the current directory. In fact, it
> > seems that the magic directory stays the same regardless of what the
> > current directory is (and whether I use an absolute or relative path).
>
> Can you reproduce this with a short script that just does the XML parsing?
>
> If so, please post that.
>
> > I'm using the current Python from Ubuntu Karmic, which is 2.6.4.
> >
> > (Somebody kindly let me know that I sent this problem to the wrong list.
> > Sorry about that, and let me know if I should take this discussion of
> > the list.)
>
> I'm not too worried about that; I'm unlikely to see this elsewhere.
>
>
> -Fred
>
More information about the Expat-discuss
mailing list