[Expat-discuss] Newbie Question

Fred L. Drake, Jr. fdrake at acm.org
Mon Apr 21 10:17:12 EDT 2003


Beckwith, Stephen @ GNS writes:
 > 1.  Is there a "single" START and END Tag call back function in one's
 > program?  IF YES, then:
 > 2.  How does one distinguish the possible "tags" that could be passed back?
 > I would think that one would setup the Parser with a list of the "expected"
 > tags to be parsed, and then equate each of these with a separate function.

You should review the documentation for XML_SetStartElementHandler();
it only sets one, and doesn't associate it with a tag name.  You can
easily wite a wrapper that does the kind of tag-based dispatch you're
suggesting.

 > However, my impression is that the parser is written to be "generic" in that
 > it only parses to the semantics of what a "tag" is (i.e. it looks for the
 > "<" and "/>") and you're left with handling the rest.  Am I correct in this
 > view? 

The tag name and attributes are parsed for you; so whether you're left
with "the rest" depends on how you define "the rest".  It's up to you
to perform dispatch based on tag name or other contextual information;
this is something that varies enough between applications that it
can't be fully general, though some widely useful idioms have been
employed (such as tag-name based dispatch).


  -Fred

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



More information about the Expat-discuss mailing list