in reply to Re: LibXML 'Fun'
in thread LibXML 'Fun'
sub start { my ($r,$params) = @_; # open the database handle and get the data from the table my $db=LMS2::Library->open_lms(); my $cat_sth = $db->prepare("SELECT * FROM CompCat ORDER BY descrip +tion "); $cat_sth->execute; my $parser = XML::LibXML->new(); my $XMLPath = $r->server_root_relative("LMS2/XML"); my $location = $r->location(); my $tree=$parser->parse_file($XMLPath."/Competancy.xml"); my $first; # prepare list of categories my @list2 = $tree->findnodes('//select[@id="categoryID"]') || warn "couldnt find any nodes for select & name of cate +goryID"; while (my $row=$cat_sth->fetchrow_hashref ) { my $node = XML::LibXML::Element->new('option'); $node->setAttribute('value',$row->{id}); if ($row->{id} == $params->{categoryID}) { $node->setAttribute('selected','selected'); } my $text = XML::LibXML::Text->new($row->{description}); $node->appendChild($text); $list2[0]->push($node); } my $parser2 = XML::LibXSLT->new(); my $ss=$parser2->parse_stylesheet_file($XMLPath."/HTMLConvert.xsl" +); my $res=$ss->transform($tree); my $htmlpage = $ss->output_string($res); $htmlpage =~ s/__HOST__/$hn{Host}/gim; $r->print($htmlpage); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: LibXML 'Fun'
by dws (Chancellor) on Oct 12, 2003 at 01:07 UTC | |
by stefzody (Acolyte) on Oct 12, 2003 at 01:56 UTC | |
by dws (Chancellor) on Oct 12, 2003 at 03:31 UTC |