in reply to Re^2: Extracting tagged data from a XML file
in thread Extracting tagged data from a XML file

The problem is that i need every IP only once. (Sorry if i didn't say that before). So i only need to get the IPAddress and not also the NEIGHBOURIPAddress, bacause then i have everything only once.
  • Comment on Re: Extracting tagged data from a XML file

Replies are listed 'Best First'.
Re^2: Extracting tagged data from a XML file
by davorg (Chancellor) on Aug 31, 2004 at 12:15 UTC

    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}++; } }
    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      Which brings me back to where I was before how do it get XPATH?

        You get all Perl modules from CPAN.

        --
        <http://www.dave.org.uk>

        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg