A method of performing a query on a Markup document, which includes steps of
receiving
a query and designing a plurality of filters to reflect a structural linkage of
a condition tree representing the query. The step of designing the plurality of
filters includes designing a highest-level filter that can become active only if
an event-based parser indicates that an element for which the highest-level filter
is searching has been found. The step of designing the plurality of filters also
includes designing a lowest-level filter that can become active only when the highest-level
filter has become active and when the parser indicates that an element for which
the lowest-level filter is searching has been parsed. The method also includes
a step of parsing a Markup document, and a step of checking the lowest-level filter
to determine whether it has found the element for which it has been searching.