Lab 2: XML Structure and Parsing

Due: Monday Feb 14, at the start of class. 30 points

Please place a copy of your code in the cs682 submit directory.

In this lab, you'll get some experience creating, displaying and parsing XML documents.

Our domain will be movies: We'll be designing an simple XML database for storing information about movies.

For the purposes of this assignment, movies have the following characteristics:

  1. (5 points) Build an XML database containing at least 10 movies using the format above.
  2. (5 points) Write a CSS stylesheet that will display your database in a web browser, one item to a line. Feel free to make it pretty!
  3. (10 points) Write a program that uses the DOM parser to provide a searchable interface to the document. The user should be able to provide an element type and value, and your program should display the corresponding data. For example:
    [brooks@zebra labs]$ python movie-interface.py
    What element would you like to find?  Title
    what value do you want?  The Godfather
    title :   the Godfather
    director: Francis Ford Coppola
    actors: Al Pacino, Marlon Brando, Robert Duvall, Diane Keaton
    rating :   5
    length :   175 min
    genre: drama
    Year Released: 1972
    

    If there's more than one match for a query, you should display all matches.

  4. (10 points) Write a program that uses the SAX parser to extract all elements with a particular tag. The use should be able to provide a tag name, and your program should show all instances of that tag. For example:
    [brooks@zebra labs]$ python SAXmovie-interface.py
    What element would you like to find?  Title
    title: The Godfather
    title: Apocalypse Now
    title: Finding Nemo
    title: Airplane!
    title: The Thin Red Line
    title: Dr. Strangelove
    title: Taxi Driver
    title: Annie Hall
    title: Crouching Tiger, Hidden Dragon