in reply to Re^2: How to access multiple values from XML file in our perl file
in thread How to access multiple values from XML file in our perl file

Semicolon missing here perhaps ?
print "@field \n"; # ^
Consider using XML::Twig
#!/usr/bin/perl use strict; use warnings; use XML::Twig; my $xml = 'value.xml'; my $twig = new XML::Twig( twig_handlers =>{ field => \&field } ); $twig->parsefile($xml); sub field { my ($t,$e) = @_; for ($e->children){ if ($_->gi eq 'key'){ print $_->att('name')." "; } elsif ($_->gi eq 'value'){ print $_->att('id')."\n"; } } }
poj

Replies are listed 'Best First'.
Re^4: How to access multiple values from XML file in our perl file
by jellisii2 (Hermit) on Jan 09, 2015 at 16:47 UTC
    This, considering the following from XML::Simple's documentation (emphasis mine):

    STATUS OF THIS MODULE ^

    The use of this module in new code is discouraged. Other modules are available which provide more straightforward and consistent interfaces. In particular, XML::LibXML is highly recommended.

    The major problems with this module are the large number of options and the arbitrary ways in which these options interact - often with unexpected results.

    Patches with bug fixes and documentation fixes are welcome, but new features are unlikely to be added.