in reply to Re: Extracting tagged data from a XML file
in thread Extracting tagged data from a XML file
If you ever need to get unique values in Perl then you should think about using a hash.
use XML::XPath; my $xp = XML::XPath->new(filename => '/path/to/file'); my %seen; foreach ('IP-ADDRESS', 'IP-NEIGHBOUR') { foreach my $ip ($xp->findnodes("//$_")) { my $addr = $ip->findvalue('.'); print "$addr\n" unless $seen{$addr}++; } }
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Extracting tagged data from a XML file
by theroninwins (Friar) on Aug 31, 2004 at 12:35 UTC | |
by davorg (Chancellor) on Aug 31, 2004 at 12:37 UTC | |
by theroninwins (Friar) on Sep 01, 2004 at 09:08 UTC | |
by davorg (Chancellor) on Sep 01, 2004 at 09:39 UTC |