SAX: Short tag's ...

David Smith dns4 at
Thu Oct 8 03:27:40 CEST 2009

Thomas Lehmann wrote:
> Hi!
> Is there a way to recognize short tags in a XML?
> I'm implementing a SAX handler...
> Problem: storing the XML code I would need this information
> in the startElement ...
> How can I handle this?
> <element id="abc" />
> <element id="xyz" >any text</element>

So ... are you writing as you read?  If so, I'm not sure you can know
which form to write out immediately.  Best bet would be to delay write
until the next SAX event.  The next SAX event will tell if the element
should be written as <element /> or <element>.


More information about the Python-list mailing list