Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Extracting tagged data from a XML file

by theroninwins (Friar)
on Aug 31, 2004 at 12:06 UTC ( #387168=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://387168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2022-05-25 04:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (84 votes). Check out past polls.

    Notices?