Murdoch University Logo B336 Advanced Internet Computing

Laboratory Week 8 & 9


Learning Objective:

  1. Learn how to use the XML::DOM module in perl to write simple XML processors.

Required Reading:

Week 7 lecture 1
Unit Reader section 5 part 10.7

Access to Software:

All required software is available in lab SC2.31.

External students may download the required software and install it on your own machine. Internal students may do the same, but are encouraged to still attend labs for supervision when doing the exercises below.

Instructions and Exercises:

  1. Copy all the example *.xml and *.pl.txt files from the examples directory into your local or network drive. Rename all the *.pl.txt files to *.pl. Read and understand what each of the perl scripts do. Try the following commands in the directory where you have your files to assist in your understanding:

    perl xml-dom1.pl poetry.xml
    perl xml-dom2.pl poetry.xml
    perl xml-dom3.pl poetry.xml

    perl xml-dom4.pl poetry.xml
    perl xml-dom5.pl poetry.xml biographies.xml | more

  2. Use the online Perl documentation for the XML::DOM module as reference, or the reference at http://theoryx5.uwinnipeg.ca/CPAN/data/libxml-enno/XML/DOM.html (the same information, but slightly better formatting).

  3. Try and write XML processors using XML::DOM to do the following:

    1. Print out all titles of poems in poetry.xml that constains the word "Rose".
    2. Transform all CDATA text in an XML file to lowercase and print the result.
    3. Delete all CDATA text lines in poetry.xml which have length more than 20 characters, and print the result.
    4. (Hard) The script xml-dom5.pl only adds to the text in an existing text node to merge information. A more elegant output format would be that the tags in biographies.xml are inserted into the tags in poetry.xml. Try and create a new file (without any a DTD) that contains these merged tags in a proper XML structure.

  4. If you haven't already, you should be thinking very seriously about Assignment 2. In the context of this laboratory, try and think of short interesting processors you can implement to add value to your solution design.

Document author: H.L. Hiew, Unit Coordinator
Last Modified: Wednesday, 18-Apr-2001 01:27:43 MST
Disclaimer & Copyright Notice © 2001 Murdoch University