XML SAX
Stano Paska
paska at kios.sk
Tue Nov 19 04:06:49 EST 2002
document root element must be only one in whole document.
<root>
<body>
</body>
<body>
</body>
</root>
Stano.
Sara wrote:
> In the Demo/xml directory of the python distribution, there is a
> "roundtrip.py" exampel of how to use the XML SAX API. The script
> basically parses an xml file, and echos the elements to standard out.
>
> I have written a very small XML file I use as input (test.xml):
>
> <body>
> </body>
> <body>
> </body>
>
> And I get an execption (see output below) from the expat parser, which
> is selected by default.
> Having just one XML "body" element works fine, but not two as in the
> example above...
>
> What is the problem?
>
> Thanx
> Sara
>
>
> % python roundtrip.py test.xml
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <body>
> </body>Traceback (most recent call last):
> File "C:\Temp\roundtrip.py", line 45, in ?
> parser.parse(sys.argv[1])
> File "C:\Python22\lib\site-packages\_xmlplus\sax\expatreader.py",
> line 109, in parse
> xmlreader.IncrementalParser.parse(self, source)
> File "C:\Python22\lib\site-packages\_xmlplus\sax\xmlreader.py", line
> 123, in parse
> self.feed(buffer)
> File "C:\Python22\lib\site-packages\_xmlplus\sax\expatreader.py",
> line 208, in feed
> self._err_handler.fatalError(exc)
> File "C:\Python22\lib\site-packages\_xmlplus\sax\handler.py", line
> 38, in fatalError
> raise exception
> xml.sax._exceptions.SAXParseException: test.xml:3:0: junk after
> document elemen
More information about the Python-list
mailing list