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
Consider using XML::Twigprint "@field \n"; # ^
poj#!/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"; } } }
|
|---|
| 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 |