XML Parsing

Alok Kothari kothari.alok at gmail.com
Tue Apr 1 16:23:16 EDT 2008


Thanks ! it worked !

On Wed, Apr 2, 2008 at 1:31 AM, Konstantin Veretennicov <
kveretennicov at gmail.com> wrote:

> On Tue, Apr 1, 2008 at 10:42 PM, Alok Kothari <kothari.alok at gmail.com>
> wrote:
>
> > Hello,
> >          I am new to XML parsing.Could you kindly tell me whats the
> > problem with the following code:
> >
> > import xml.dom.minidom
> > import xml.parsers.expat
> > document = """<token pos="nn">Letterman</token><token pos="bez">is</
> > token><token pos="jjr">better</token><token pos="cs">than</
> > token><token pos="np">Jay</token><token pos="np">Leno</token>"""
> >
>
> This document is not well-formed. It doesn't have root element.
>
> ...
>
>
> >
> > Traceback (most recent call last):
> >  File "C:/Python25/Programs/eg.py", line 20, in <module>
> >    p.Parse(document, 1)
> > ExpatError: junk after document element: line 1, column 33
> >
>
> Told ya :)
>
>
> Try wrapping your document in root element, like
> "<tokens><token>...</token><token>...</token></tokens>"
>
> --
> kv
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080402/2fd36bce/attachment-0001.html>


More information about the Python-list mailing list