#!/usr/bin/perl -w
# Woot! The second version.
$VERSION = 0.02;
# like a good little coder
use strict;
# required modules
use Apache;
use XML::DOM;
use HTML::Template;
use vars qw($parsed_xml);
# move this sort of stuff to a .conf file later
my $xml_file = '/home/iordy/perl.iordy.net/iXML_base.xml';
# Read and parse the document
my $parser = XML::DOM::Parser->new();
$parsed_xml = $parser->parsefile ($xml_file);
## main ##
# &process_args(); #process arguments and move on from there.
my $page_content = "page content";
&showpage($page_content);
## subs ##
sub search {
my ($search_for_section) = @_;
my @search_section_results;
foreach my $node ($parsed_xml->getElementsByTagName('section_id')){
if ($node->getAttibute('section_name') eq $search_for_section) {
push @search_section_results,$node->getAttribute('section_id');
}
}
return @search_section_results;
}
sub process_args {
my $r = Apache->request;
my %arguments = $r->args;
my $page_content;
foreach my $key (keys %arguments) {
my $arg = $arguments{$key};
#swap this to a switch later?
if ($arg eq 'search') {
foreach my $search_result (&search($arg)){
$page_content .= $search_result . "
";
}
}
else{
$page_content = "Page Error: No valid argument specified!";
}
}
&showpage($page_content);
}
# note: make this a package later on, plus add in all the other attributes that a page will need.
sub showpage {
my ($page_content) = @_;
my $r = Apache->request;
$r->send_http_header('text/html');
$r->print($page_content);
}
####