holygrail has asked for the wisdom of the Perl Monks concerning the following question:
So here is the XML file (called test.xml):bash-2.03$ tpage template.html undef error - junk after document element at line 18, column 0, byte 221: </section> </site> <site language="fr"> ^ <section name="section 1"> <intro> at /usr/local/lib/site_perl/i386-linux/XML/Parser.pm line 185
and here is the template (called template.html):<?xml version="1.0"?> <site language="en"> <section name="section 1"> <intro> My darling </intro> <maintext> I love you </maintext> </section> <section name="section 2"> <maintext> The Bla </maintext> </section> </site> <site language="fr"> <section name="section 1"> <intro> mon amour </intro> <maintext> Je t'aime </maintext> </section> <section name="section 2"> <maintext> bla </maintext> </section> </site>
when I remove the "french" part of the XML page (everything after the first </site>), it works like it should[% USE xpath = XML.XPath(file => "./test.xml") %] [% FOREACH site = xpath.findnodes('site') %] <h1>[% site.getAttribute('language') %]</h1> [% FOREACH section = xpath.findnodes('site/section') %] <h2>[% section.getAttribute('name') %]</h2> [% maintext = section.findnodes('maintext') %] [% maintext.string_value %] [% END %] [% END %]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Template Toolkit && XPath plugin
by davorg (Chancellor) on Jun 26, 2001 at 20:32 UTC | |
|
Re: Template Toolkit && XPath plugin
by Anonymous Monk on Jun 26, 2001 at 20:31 UTC |