Jump to content


Perl XML: parse

  • Please log in to reply
No replies to this topic

#1 vietboy505

  • Members
  • PipPip
  • Member
  • 16 posts

Posted 04 March 2006 - 05:27 AM

I try to follow the example from [a href=\"http://search.cpan.org/~grantm/XML-Simple-2.14/lib/XML/Simple.pm\" target=\"_blank\"]XML Parse[/a] with foo.


use XML::Simple;

my $ref = XMLin('foo.xml');

#also with my $ref = XMLin();

use Data::Dumper;

print Dumper($config);
print $config->{logdir};

where foo.xml
  <config logdir="/var/log/foo/" debugfile="/tmp/foo.debug">
    <server name="sahara" osname="solaris" osversion="2.6">
    <server name="gobi" osname="irix" osversion="6.5">
    <server name="kalahari" osname="linux" osversion="2.0.34">

I try to test out foo.pl and get
$VAR1 = undef;
Why is that, it doesn't match the one with from the web.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users