[Expat-discuss] empty tags

Fred L. Drake, Jr. fdrake@acm.org
Fri, 10 Aug 2001 09:10:51 -0400 (EDT)

Sylvain PRAT writes:
 > I would like to know if there's a mean to know if the
 > read tag is empty : in fact, i would like to re-fit
 > the tags i don't want to recognize (both start and end
 > elements), so i expected to use the input context
 > associated to the byte count to do that, but i think
 > empty tags will cause problems because they will be
 > duplicated... Another way to do that ?

  I think the only way to tell the difference betwee <e/> and <e></e>
is to use the input context.  The simplest way would be to check it
for the end tags; if it starts with "</", the element did not use
empty element notation.  Checking this should be easy & fast (the call
to get the input context will be more expensive than the check!), but
you should be careful; if you have an empty element tag with a *lot*
of attributes, the beginning of the tag may not be there any more.
See the caveats in the documentation for more information.


Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation