CmpSc 421, Spring 2013 , XML Parsing Assignment

For this assignment, you will create a Java desktop application, XML_Parsing. In this project, you will create both DOM and SAX parsers to process the file reed.xml You will also need reed.dtd.

Part I (

Write a DOM parser to determine the number of courses in reed.xml. Then, output a list of all subjects and the number of courses in each subject, alphabetically by subject. A sample run will look like:

There are 703 courses. By subject, 

ANTH => 23
ART => 23
BIOL => 56
CHEM => 64
CHIN => 8

You will need to store name-value pairs as you process nodes and then output these after you encounter the end of the XML document. I suggest checking out Java's TreeMap class.


Part II: (

Write a SAX parser to retrieve all the math course names and sections from reed.xml, and then output them alphabetically. A sample run will look like:

Abstract Algebra.S
Advanced Calculus.F
Algebraic Structures.F
Calculus I.F01
Calculus I.F02
Calculus I.F03

For this processing, you may want to use a TreeSet or simply an ArrayList.



  1. By noon on Tues, Apr. 09, place your XML_Parsing project in your drop folder. Include your .xml and .dtd files also.
  2. Complete one integrity statement for the entire project and date and sign it.
  3. At the beginning of class on Tues, Apr. 09, turn in well-formatted and readable copies of your integrity statement, all .jsp and .java files, and runs of your parsers.