in reply to Re: Parsing XML file for more than 1 child element with attributes
in thread Parsing XML file for more than 1 child element with attributes

Thanks. Using Data Dumper i was able to see the tree structure and this is the structure that i was looking for. I tried the for loop that you have provided "foreach $node ( keys( %{ $tree->{report}->{node} } ) ) { print "$node:values: $tree->{report}->{node}->{$node}->{values}\n"; }" But here what i observe is that the keys are obtained as mid, time name and values. I am trying to accomplish something like " if the mid is 'machine1' and name is 'Winxp' then i would like to get the 'time' and 'values'. " Similary i will loop across many mid and names. Since i already know the mid and name, it is easy. But the problem is how to construct code for this task ?
  • Comment on Re^2: Parsing XML file for more than 1 child element with attributes

Replies are listed 'Best First'.
Re^3: Parsing XML file for more than 1 child element with attributes
by Cody Pendant (Prior) on Feb 06, 2008 at 21:43 UTC
    Well, I think the reason nobody's helping you is, you haven't shown any of your own code yet.

    If you understand how

    foreach $node ( keys( %{ $tree->{report}->{node} } ) ) { print "$node:VALUES: $tree->{report}->{node}->{$node}->{values}\n"; }
    works, then you should be able to just add an "if" to my code to get what you want. If you don't, or if you don't even know how to do "if", in Perl, you'd better say so.


    Nobody says perl looks like line-noise any more
    kids today don't know what line-noise IS ...