#!/usr/bin/perl --
# program to read a XML file and display it as HTML.
# XML::Simple is used to read the file into a complex hash of hashes of
# arrays (or some such structure).
use XML::Simple;
my $item;
# turn the file into a hash; use forcearray so that all elements are arrays.
# we might want to eval this in real life to check for "well-formedness",
# depending on efficiency considerations.
my $STILLS = XMLin('./stills.xml',forcearray=>1);
#use Data::Dumper;
#print Dumper($STILLS); # use this for debugging.
#Get the input
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
#Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair);}
$name=$ENV{'QUERY_STRING'};
# print a header for the web page.
print <{ITEM}} ) )
{
exit;
}
for my $STILLS ( @{$STILLS->{ITEM}} )
{
if (($STILLS->{NAME}) eq $name) # wait until we come across the name we're looking for in the XML file
{
print " $STILLS->{'TITLE'}->[0]\n";
if ( defined @{$STILLS->{'COMMENT'}} )
{
print " Editors Note: $STILLS->{'COMMENT'}->[0].\n";
}
print " \n";
print " \n";
print " {'WIDTH'}} )
{
print "width='$STILLS->{'WIDTH'}->[0]' ";
}
if ( defined @{$STILLS->{'HEIGHT'}} )
{
print "height='$STILLS->{'HEIGHT'}->[0]' ";
}
print ">\n";
if ( defined @{$STILLS->{'SUBMITTED_BY'}} )
{
print " This photo was submitted by $STILLS->{'SUBMITTED_BY'}->[0].\n";
}
print ' Click SUBMIT in the menu above to submit your photos or video clips!';
print "\n ";
print "\n \n";
}
}
exit;
|
|