[Templates] Using XML::Smart with template toolkit

Robert Clarke robert.clarke@gmgrd.co.uk
Thu, 29 Jun 2006 16:15:04 +0100


  =20
 Hi
I'm trying to access values from XML using the XML::Smart module ( =
http://search.cpan.org/dist/XML-Smart/lib/XML/Smart.pm)

Assuming that I have some XML like this

<person>
  <name>mr jones</name>
  <contact>
    <telephone>01234 5678910</telephone>
  </contact>
</person>

I can create an XML::Smart object using this XML and access the values =
in perl as follows:

$telephoneno =3D $myxml->{person}->{contact}->{telephone};

If I pass the XML::Smart object into a TT template I would expect this =
to display the telephone number

[% myxml.person.contact.telephone %]

However it doesn't display anything, and doesn't throw an error either. =
I suspect that this has something to do with the way in which XML::Smart =
hides the differences between Hashrefs and Arrayrefs (see: =
http://search.cpan.org/dist/XML-Smart/lib/XML/Smart.pm#WHY_AND_HOW_IT_WOR=
KS)

Can anyone think of a way around this? I'm using Template Toolkit 2.14 =
with Catalyst

Thanks for your help,
Rob  =20
--------------------------------------------------------
GMG Regional Digital is part of the Guardian Media Group plc.=20
=20
=20
 =20
=20
CONFIDENTIALITY NOTICE. The information contained in this e-mail is =
intended only for templates@template-toolkit.org. It may contain =
privileged and confidential information that is exempt from disclosure =
by law and if you are not an intended recipient, you must not copy, =
distribute or take any action in reliance on it. If you have received =
this e-mail in error, you may notify us by telephone on 44 (0)161 832 =
7200. E-mail transmission cannot be guaranteed to be secure or =
error-free. The sender (robert.clarke@gmgrd.co.uk) therefore does not =
accept liability for any errors or omissions in the contents of this =
message, which arise as a result of e-mail transmission. If verification =
is required please request a hard-copy version. =20
 =20
 =20
 =20
 =20
=20
=20