xml processing : too slow...

Shagshag13 shagshag13 at yahoo.fr
Thu Jul 25 06:31:24 EDT 2002


"Fredrik Lundh" <fredrik at pythonware.com> a écrit dans le message de news: j5C%8.677$HY3.191054 at newsc.telia.net...
>
> from xml.parsers import expat
> parser = expat.ParserCreate(None, None)
>
> import re
> p = re.compile("<[^>]*>|\d+")
>
> for line in file:
>     # check wellformedness
>     parser.Parse(line, 0)
>     # split into parts
>     print p.findall()
>
> # check for trailing junk
> parser.Parse("", 1)
>
> </F>

sorry to bother, but i get "ExpatError: junk after document element: line 1, column 188" and don't understand what it mean...

>>> t = """<tag0><tag1> 1 2 </tag1><tag2 attr="value">3</tag2></tag0>"""
>>> parser.Parse(t, 0)
Traceback (most recent call last):
  File "<pyshell#33>", line 1, in ?
    parser.Parse(t, 0)
ExpatError: junk after document element: line 1, column 188

thanks,

s13.





More information about the Python-list mailing list