GeneralPrint like this in pdf

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
clar
Posts: 7
Joined: Fri Oct 21, 2011 6:22 pm

Print like this in pdf

Post by clar »

Hi i am creating latex template using perl and executed using MikTex(pdflatex)compiler.I am getting wrong output

Code: Select all

#!/usr/bin/env perl
     use strict;
     use warnings;
      use XML::Fast;
      use Template;

     my $xml = <<'XML';
              <student>
                 <number>24</number>
                 <education>bachelors</education>
                  <specialization>computers </specialization>
                   <address>
                    <house_number="128"/>
                     <street name="xxxx"/>
                    <proddutoor/>
                    </address>   
                </student>
                <student>
                 <number>23</number>
                  <education>ph.d.</education>
                   <specialization>physics </specialization>
                   <address>
                    <house_number="12"/>
                    <street name="xxxx"/>
                     <kadapa/>
                   </address>
                  </student>
                XML
           my $xml_hash = xml2hash $xml;

          my $template = Template->new();

           my $filename = 'output.tex';
    $template->process(\*DATA, $xml_hash, $filename)
      || die "Template process failed: ", $template->error(), "\n";

    system( "pdflatex $filename" );

       __DATA__
       \documentclass{article}

      \title{Roster}
       \author{pavani}

     \begin{document}
       \maketitle

    [% FOREACH st IN student %]
    Student [% st.number %] is a [% st.specialization %] [% st.degree %] student and          
     his address is[%address%][%house_number%][%street name%].
     [% END %]

     \end{document}
this is my perl script and after running its genarating pdf like this

Code: Select all

student 24 is a computers student and his address is HASH(0x274b27c)
student 23 is a computers student and his address is HASH(0x274b27c)
but I need to print address also how to get the address element content also like this

Code: Select all

student 24 is a computers student and his address is 
                       house_number="128";
                       street name="xxxx";
                        proddutoor.
student 23 is a computers student and his address is 
                     house_number="12";
                       street name="xxxx";
                     kadapa.

what should I need to change to print like this in pdf.

2) I have one more question if I am giving input like this XML data its excuting what can I do if I have one file with data same as like this,for example more number of students data in one file.I tried to give file name to variable xml but its not working.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply