XML SAX

Paul Simmonds psimmo60 at hotmail.com
Tue Nov 19 04:19:19 EST 2002


>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?

This looks like an XML well-formed-ness question. XML requires that 
everything is inside one top level element. So:

<? xmlversionstuff>
<mydoc>
<body>
</body>
<body>
</body>
</mydoc>

will work, but without the mydoc tag, it's not well-formed. Check out

http://www.xml.com/pub/a/98/10/guide3.html#WELLFORMED

If you're using the basic SAX parser, SAXParseExceptions are caused by the 
document you're feeding it.

HTH,
Paul

>Thanx
>Sara

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail





More information about the Python-list mailing list