in reply to Extracting information from XML file

Don't know how to do it "your" way, but this seems to work:
#!/usr/bin/perl use strict; use warnings; use diagnostics; use XML::Simple; my $data = XMLin("/path/to/report.xml"); for ( @{ $data->{'report'} } ) { print "Report name: $_->{'report-name'}\n"; }


($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print

Replies are listed 'Best First'.
Re^2: Extracting information from XML file
by Nesh (Beadle) on Apr 14, 2005 at 22:23 UTC
    Hi Thanks a lot for your help. The method you suggested worked fine, but I am still confused as to how to go one level deeper into it. Like how to extract the values of source path and destination path. I only get hash values and not the real values. Please help.
      OK I'm a bit busy.

      This works but it's ugly and doesn't run under strict for some reason I'll figure out later.

      #!/usr/bin/perl use XML::Simple; my $data = XMLin("/path/to/report.xml"); for ( @{ $data->{'report'} } ) { print "Report name: $_->{'report-name'}\n"; foreach my $key ( keys( %{ $_->{'source-file'} } ) ) { print "source file path: " . $_->{'source-file'}->{"$key"} ->{'source-file-path'} . "\n"; } foreach my $key ( keys( %{ $_->{'destination-file'} } ) ) { print "destination file path: " . $_->{'destination-file'}->{"$key"} ->{'destination-file-path'} . "\n"; } }

      The thing I'd do, if it were me, is mess about a bit with the options of XML::Simple, so that the data structure was a bit easier to access.



      ($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
      =~y~b-v~a-z~s; print