Running DOMFilter

 

DOMFilter parses an XML document, searching for specific elements by name, or elements with specific attributes.

Requirements:

  • XML4J is loaded on your computer
  • JDK is loaded on your computer.

Source code:

DOMFilter

 

To run DOMFilter

  1. open up a msdos command line window
  2. set the path to the jdk\bin directory
  3. change directory to the latest xml4j directory
  4. invoke the DOMFilter parser

On Windows:

The easiest way to do this is to create a .bat file using the Notepad editor. Then the DOMFilter can be invoked by double clicking on the file name or icon. The following command lines assume that both the jdk and the xml4j directories are located directly below the c: dirve.

set path=c:\jdk1.1.8\bin;%PATH%
set classpath=c:\xml4j_2_0_13\xml4j.jar;%CLASSPATH%
set classpath=c:\xml4j_2_0_13\xml4jSamples;%CLASSPATH%
cd c:\xml4j_2_0_13
java dom.DOMFilter data\personal.xml

Switches:

DOMFilter also allows you to change the default behavior via the following command line flags:

  • -p Specify the parser class to be used. The available parsers are:
              dom.wrappers.NonValidatingDOMParser
              dom.wrappers.DOMParser [default parser]
              dom.wrappers.TXParser
  • -h Print DOMFilter help information. [default is no help]
  • -e Specify the name of the element to search for. [defaults to matching all elements]
  • -a Specify the name of the attribute to search for. [defaults to matching all attributes]

Running DOMFilter with the default settings is equivalent to running DOMFilter like this (type this in as one long command line):

    java dom.DOMFilter -p dom.wrappers.DOMParser
        data\personal.xml

Bringing up the help information:

    java dom.DOMFilter -h

Searching for elements:

    java dom.DOMFilter -e family data\personal.xml

Search for all attributes:

    java dom.DOMFilter -a data\personal.xml

Note: Parse your own XML file instead of data\personal.xml

Return to Parsers