Hi,
I really don't have a clue what is going on. I have a very simple XML file (see below), and an even simpler template. When I try to run this through
tpage template.html it barfs out with the following error:
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
So here is the XML file (called test.xml):
<?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>
and here is the template (called template.html):
[% 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 %]
when I remove the "french" part of the XML page (everything after the first </site>), it works like it should
Anyone?
--HolyGrail