#!/usr/bin/perl -w -I.
use strict;

use FindBin;
use lib "$FindBin::Bin/../../../../../public_html/cgi-bin/ODL-Box-2.0/lib";

use Pure::EZXML;
use Data::Dumper;

sub main
{
   chdir "$FindBin::Bin";

#   my $parser = new Pure::EZXML;
   
#   my $document = $parser->parsefile ("uct.xml");
#   print $document->getDocumentElement->getElementsByTagName ('title')->item(0)->getFirstChild->getData;

   # create instance of parser
#   my $parser = new Pure::EZXML; 
   # parse document
#   my $document = $parser->parsefile ("uct.xml"); 
   # get node of root tag
#   my $root = $document->getDocumentElement;
   # get list of title elements
#   my $title = $document->getElementsByTagName ('title');
   # get first item in list
#   my $firsttitle = $title->item(0);
   # get first child - text content
#   my $text = $firsttitle->getFirstChild;
   # print actual text
#   print $text->getData."\n";
   
   my $parser = new Pure::EZXML;
   my $document = $parser->parsefile ("uct.xml")->getDocumentElement;
   foreach my $title ($document->getElementsByTagName ("title"))
   {
      print "<title>".$title->getFirstChild->getData."</title>\n";
   }
   foreach my $author ($document->getElementsByTagName ("author"))
   {
      print "<creator>".$author->getFirstChild->getData."</creator>\n";
   }
   print "<publisher>UCT</publisher>\n";
   foreach my $version ($document->getElementsByTagName ("version"))
   {
      foreach my $number ($version->getElementsByTagName ("number"))
      {
         print "<identifier>".$number->getFirstChild->getData."</identifier>\n";
      }
   }
}

main;
