BZip2 decompression and parsing XML

phasma xpahos at gmail.com
Fri Jun 6 15:02:44 CEST 2008


Hi.

I'm trying to disassemble bzipped file. If I use minidom.parseString,
I'm getting this error:

Traceback (most recent call last):
  File "./replications.py", line 342, in ?

  File "/usr/lib64/python2.4/xml/dom/minidom.py", line 1925, in
parseString
    return expatbuilder.parseString(string)
  File "/usr/lib64/python2.4/xml/dom/expatbuilder.py", line 940, in
parseString
    return builder.parseString(string)
  File "/usr/lib64/python2.4/xml/dom/expatbuilder.py", line 223, in
parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line
538676, column 17

If I use minidom.parse, I'm getting this error:

Traceback (most recent call last):
  File "./replications.py", line 341, in ?
    files.xml = minidom.parse(bz2.decompress(dump))
  File "/usr/lib64/python2.4/xml/dom/minidom.py", line 1915, in parse
    return expatbuilder.parse(file)
  File "/usr/lib64/python2.4/xml/dom/expatbuilder.py", line 922, in
parse
    fp = open(file, 'rb')
IOError

But XML parsed normally.

Code:

            try:
                handler = open(args[0], "r")
                dump = handler.read()
                handler.close()
            except IOError, error:
                print("Can't open dump: %s" % error)
                sys.exit(1)

            files.xml = minidom.parse(bz2.decompress(dump))




More information about the Python-list mailing list