Exercises


  1. Given the CSV data shown in the following, create a file named exer_1.csv . Write a Perl program using the XML::SAXDriver::XML module that will convert the CSV file to XML.

    Name the root element <exercise1> and then use the first column names as the element names (hint: Dynamic_Col_Headings ). Use the XML::Handler::YAWriter as the event handler. Generate a new file named exer_1.xml containing the results.

     Class,Teacher,Time,Room,Lab  Biology,Mrs. Riehl,10:00 - 11:00,103,Y  Marine Science,Mrs. Riehl,11:30 - 12:30, 103,N  Algebra,Mr. McCarthy,1:00 - 2:00,114,N  Computer Science,Mr. Burns,3:00 - 4:00,204,Y 
  2. Now modify the program and write your own handler to handle the CSV data. Don't forget to take out the XML::Handler::YAWriter dependency (that is, use XML::Handler::YAWriter as well as the Handler assignment).

For suggested solutions to all these exercises, be sure to check out the book's web site.



XML and Perl
XML and Perl
ISBN: 0735712891
EAN: 2147483647
Year: 2002
Pages: 145

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net