use XML::Simple;
use Data::Dumper;
my $config = XMLin();
print Dumper($config);
which will produce something like this (formatting has been adjusted
for brevity):
{
'logdir' => '/var/log/foo/',
'debugfile' => '/tmp/foo.debug',
'server' => {
'sahara' => {
'osversion' => '2.6',
'osname' => 'solaris',
'address' => [ '10.0.0.101', '10.0.1.101' ]
},
'gobi' => {
'osversion' => '6.5',
'osname' => 'irix',
'address' => '10.0.0.102'
},
'kalahari' => {
'osversion' => '2.0.34',
'osname' => 'linux',
'address' => [ '10.0.0.103', '10.0.1.103' ]
}
}
}
--- This is a print out the POD file of XML::Simple, one of the first
results when searching for "xml" on http://search.cpan.org/.
So you can do $xml->{username}->{password} or anything like that.
On Thu, Nov 6, 2008 at 5:41 PM, Oren Maurer <[EMAIL PROTECTED]> wrote:
>
> I have seen a PHP code like this
>
> ==============================
> $xml = simplexml_load_file($request);
>
> // items
> $Base = $xml->Items->Item;
> ==============================
>
> I want to try it in Perl.
> Is there an equivalent to the simplexml_load_file() function?
>
>
> Additional info - In: http://il.php.net/simplexml_load_file
> I see this:
>
> ============================
> simplexml_load_file
>
> (PHP 5)
>
> simplexml_load_file — Interprets an XML file into an object
> Description
> object simplexml_load_file ( string $filename [, string $class_name [,
> int $options [, string $ns [, bool $is_prefix ]]]] )
>
> Convert the well-formed XML document in the given file to an object.
>
> ....
> [See more on http://il.php.net/simplexml_load_file ]
>
> ============================
>
> Thanks in advance.
>
> --
> ________________________________
> Oren Maurer
> http://www.meorero.org.il
> _______________________________
> # =======================|
> # Please avoid sending me Word |
> # or PowerPoint attachments |
> # =======================|
> # See: http://www.gnu.org/philosophy/no-word-attachments.html
> _______________________________________________
> Perl mailing list
> [email protected]
> http://perl.org.il/mailman/listinfo/perl
_______________________________________________
Perl mailing list
[email protected]
http://perl.org.il/mailman/listinfo/perl