SAX Xml Problem
Darren Young
darren at younghome.com
Fri Sep 1 12:04:37 EDT 2000
I am getting the following error:
Reading /usr/local/src/yhl/src/installer/manifext.xml
Traceback (innermost last):
File "./dl.py", line 29, in ?
parser.parseFile(file)
File
"/usr/lib/python1.5/site-packages/xml/sax/drivers/drv_pyexpat.py", line
77, in parseFile if not self.parser.Parse(fileobj.read(),1):
AttributeError: 'string' object has no attribute 'read'
When I run the following code:
#!/usr/bin/python
#
from xml.sax import saxexts
from xml.sax import saxlib
class FindSource(saxlib.HandlerBase):
def __init__(self, name):
self.search_name = name
def startElement(self, elemName, attrs):
print "Starting element: ", name
#if elemName != 'source' : return
name = attrs.get('name', None)
if name == self.search_name:
print name, 'found'
if __name__ == '__main__':
file = "/usr/local/src/yhl/src/installer/manifest.xml"
print "Reading", file
parser = saxexts.make_parser()
dh = FindSource('Bash')
parser.setDocumentHandler(dh)
parser.parseFile(file)
parser.close()
Any ideas would be wonderful...
Thanks,
Darren Young
More information about the Python-list
mailing list