[XML-SIG] Parser not resetting

Josh English joshua.r.english at gmail.com
Sat Jul 19 17:27:13 CEST 2008

I have a file of XML-data objects. I wrote a ContentHandler to search
for elements and return them in a variety of formats. Once I plugged
all this into a GUI I discovered a strange problem. The function call
tells a parser to parse the same source file, but it stops reading the
source file and limits searching to previously found results.

I'm using a ConfigParser object to determine what to match, but I
don't think this is the problem.

The code uses an xml.sax.handler.ContentHandler subclass,  that stores
the results in "output" and the filter function is :

def list_submissions(argstring,filters={}):
    parser = make_parser()

    return sh.output

running this function over and over causes the problem

print len(list_submissions("--dict")  # Get all submissions as
dictionary objects
print len(list_submissions("-mAsmv --dict") # Get all submissions to
this this market
print len(list_submissions("--dict") # Get all submissions again

the results:


The last call should give me 152.

I'm not finding a method to reset a parser. I've tried deleting the
parser object in the function, deleting the parser and the content
handler object in the function, but nothing seems to solve this

Has anyone seen this? I'm running Python 2.5.1 (r251:54863, Apr 18
2007, 08:51:08) [MSC v.1310 32 bit (Intel)], using the standard xml
files with this distribution.


Josh English
Joshua.R.English at gmail.com

More information about the XML-SIG mailing list