in reply to Re: 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

Even i tried that one by changing that braces. But it is also showing error as "syntax error at field.pl line 15, near ") {" syntax error at field.pl line 18, near "}" Execution of field.pl aborted due to compilation errors."

  • Comment on Re^2: How to access multiple values from XML file in our perl file

Replies are listed 'Best First'.
Re^3: How to access multiple values from XML file in our perl file
by poj (Abbot) on Jan 09, 2015 at 16:13 UTC
    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
      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.

Re^3: How to access multiple values from XML file in our perl file
by Lotus1 (Vicar) on Jan 09, 2015 at 14:56 UTC