Hi
<university>
<name>svu</name>
<location>ravru</location>
<branch>
<electronics>
<Section>
<student name="xxx" number="12">
<sem semister="1"subjects="7" rank="1"/>
<sem semister="2"subjects="4" rank="1"/>
<student>
<student name="xxx" number="15">
<sem semister="1"subjects="7" rank="10"/>
<sem semister="2"subjects="4" rank="1"/>
<student>
<student name="xxx" number="16">
<sem semister="1"subjects="7" rank="2"/>
<sem semister="2"subjects="4" rank="2"/>
<student>
</section>
</electronics>
</branch>
</university>
<university>
<name>sku</name>
<location>ANTP</location>
<branch>
<computers>
<Section>
<student name="xxx" number="12">
<sem semister="1"subjects="7" rank="no"/>
<sem semister="2"subjects="4" rank="no"/>
<student>
<student name="xxx" number="15">
<sem semister="1"subjects="7" rank="10"/>
<sem semister="2"subjects="4" rank="1"/>
<student>
<student name="xxx" number="16">
<sem semister="1"subjects="7" rank="20"/>
<sem semister="2"subjects="4" rank="21"/>
<student>
</section>
</electronics>
</branch>
</university>
我使用了XML:Simple和I生成了散射结构数据并储存在一个变量中。 我使用了模板:toolkit生成pdffile(使用pdflatex)。 我的XML:简单产出就是这样。
$var1={
university=>{
name => svu ,
location => ravru ,
branch =>{
electronics =>{
section =>[
{
name => xxx ,
number => 12 ,
sem =>[
{
semister => 1 ,
subjects => 7 ,
rank => 1
},
{
semister => 2 ,
subjects => 4 ,
rank => 1
}
]
},
{
name => xxx ,
number => 15 ,
sem =>[
{
semister => 1 ,
subjects => 7 ,
rank => 10
},
{
semister => 1 ,
subjects => 7 ,
rank => 1
}
]
},
{
name => xxx ,
number => 16 ,
sem =>[
{
semister => 1 ,
subjects => 7 ,
rank => 2
},
{
semister => 2 ,
subjects => 4 ,
rank => 2
}
]
}
}
]
}
};
like this I have 15 universities and also some section having only two or three students some having 10 students, in students some body only one sem some having two semesters like that.I written template like this
my $template = Template->new();
my $filename = output.tex ;
$template->process(*DATA, $data, $filename)
|| die "Template process failed: ", $template->error(), "
";
system( "pdflatex $filename" );
__DATA__
documentclass[a4paper,leqno,twoside]{article}
egin{document}
[% FOREACH st = university %]
[%+ st.name +%]
[%+ st.location +%]
[% FOREACH section = st.branch.electronics.section %]
branch student: [%+ section.name +%]
[%+ section.number +%]
[% FOREACH sem = section.sem %]
[%+ sem.semister +%]
[%+ sem.subjects +%]
[%+ sem.rank +%]
[% END %]
[% END %]
[% END %]
/end{document}
like this it giving output but My problem is its too lengthy and also I said above some section have two students and some sections have more than two. for example first section contains 1 student and second section contains 10 students like that. but in pdf first section also printing 10 students only first student have information remaining all empty. how can I eliminate this problem. If you dont understand my problem just how can I get the data using shorter code than i written. is there any other way to get branch elements all with simpler using for loop for branch elements or any simple code.because if some section have 60 students so it printing 6o in every section.