veeru reddy wrote:
> Hi,
> I have XML file with more number of university's like this as shown
> below
OK, now we see the structure, we know that the XML is not relevant.
> I used XML::Simple to store this data into one hash data structure
> variable $data and that information is like this
And we know it is this data structure that is relevant.
> $var1={
> university=>{
> 'name'=>'svu',
> 'location'=>'ravru',
> 'branch'=>{
> 'electronics'=>{
> 'student'=>[
> {
> 'name'=>'xxx',
> 'number'=>'12',
> 'semester'=>{
> 'Number'=>'1',
> 'subjects'=>'7',
> 'rank'=>'1'
> }
> },
> {
> 'name'=>'xxx',
> 'number'=>'15',
> 'semester'=>[
> {
> 'number'=>'1',
> 'subjects'=>'7',
> 'rank'=>'10'
> },
> {
> 'number'=>'1',
> 'subjects'=>'7',
> 'rank'=>'1'
> }
> ]
> },
[snip]
> But I getting Different output rather than what I want.
> After executing this script I am getting output when I have three or
> more students in electronics and two or more semesters for each
> student then only I am getting. otherwise it does print any thing just
> printing studentdata: three times . for example if I have one student
> with one semester in university at that situation it doesn't give any
> thing it printing like this
> studentdata:
> studentdata:
> studentdata:
I'm not sure I believe that. You just claimed it and didn't provide the
computer output so I can't check. But I don't think that's exactly the case.
> like as above ,I identified the problem is I have three attributes in
> student element "name""number" and "semester" like this so it printing
> three times If I add one more attribute in between name and number in
> student element it printing four times. It means something wrong with
> second for loop but I cant rectify it. I tried alot . how can I
> rectify and how can I print data like this in pdf.
This sounds like a homework problem, so I'm not going to tell the answer
directly. If it isn't homework, I apologize for seeming reluctant to
help. But look closely at the data structure and figure out *exactly*
what the data structure is. Then make sure you are using the correct TT
syntax to address that data type.
If you come back with more data and evidence that you've worked things
out, there's a particular peculiarity of TT involved here that we can
explain. The long and short of it is that you're better analysing the
data structure in perl rather than TT.
Cheers, Dave
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates