How Filter Criteria is Set
One of the benefits of this sample application is that the code can return an element and its contents from any XML document. To achieve this, the Command1_Click() procedure contains a statement that calls the SetFilterCriteria
method in the ContentHandlerImpl
class and passes it the value of the Text3 text box, as shown in the following code.
cnth.SetFilterCriteria (Text3.Text)
The following shows the SetFilterCriteria
method in the ContentHandlerImpl
class. The FilterCriteria
variable is declared in the general section of the ContentHandlerImpl
class.
Public Sub SetFilterCriteria(elementname)
FilterCriteria = elementname
End Sub
The value of the FilterCriteria
variable is then tested in the startElement
method in the ContentHandlerImpl
class to determine if the specified element is within scope. The code to test FilterCriteria
in the ContentHandler
methods, along with a full code listing for the ContentHandlerImpl
class, is included in the following topic.