> Newbie question:
> I have a XML-file wich contains details of cars. How do I use 
> TT with one template to generate one HTML-page for each car? 

You can also use one template by moving the loop to your perl code:

__SAMPLE_CODE__
#!/usr/bin/perl -w
use strict;
use XML::XPath;

my $doc = XML::XPath->new(filename=>'cars.xml');

foreach my $carNode ($doc->findnodes('/cars/car')) {
    my $car = {
               status => $carNode->getAttribute('status'),
               price => $carNode->findvalue('price')->value(),
               ...
              };
    $tt->process('car.tt',$car) or die $tt->error();
}

__END__

-- 
Mark Thomas


_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to