http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Charter
Release Info

Installation
Download

FAQs
Samples
API Docs

Features
Properties

XML Schema
Caveats
Feedback
Y2K Compliance

Source Repository
User Mail Archive
Dev Mail Archive

Running DOMFilter
 

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

Requirements:

  • Xerces-J is loaded on your computer.
  • JDK is loaded on your computer.

Source code:

  • DOMFilter.java

DOMFilter
 

To run DOMFilter:

  1. open up a MS-DOS command line window
  2. set the path to the jdk\bin directory
  3. change directory to the latest xerces-1_4_4 directory
  4. invoke the DOMFilter sample

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 xerces-1_4_4 directories are located directly below the c: dirve.

set PATH=%PATH%;c:\jdk1.1.8\bin
set CLASSPATH=%CLASSPATH%;c:\xerces-1_4_4\xerces.jar;c:\xerces-1_4_4\xercesSamples.jar
cd c:\xerces-1_4_4
java dom.DOMFilter data/personal.xml

Switches:

DOMFilter also allows you to change the default behavior using the following command line flags (type this in as one long command line):

  • -p Specify the parser class to be used.
    The available parsers are:
    • dom.wrappers.DOMParser [default parser]
  • -h Print DOMCount 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:

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 attributes:

java dom.DOMFilter -a subordinates data/personal.xml
NoteParse your own XML file instead of data/personal.xml


Copyright © 1999-2005 The Apache Software Foundation. All Rights Reserved.