Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Is there any XML reader like this?

by toolic (Bishop)
on Jan 13, 2012 at 22:04 UTC ( #947839=note: print w/replies, xml ) Need Help??

in reply to Is there any XML reader like this?

I'm not sure why you don't think you can use XML::Simple to parse your XML file, but here is one way to print all ip's for station17, for example:
use warnings; use strict; use XML::Simple; my $str = ' <servers> <station18> <ip></ip> <ip></ip> <ip></ip> <ip></ip> <ip></ip> </station18> <station19> <ip></ip> <ip></ip> <ip></ip> <ip></ip> <ip></ip> </station19> <station17> <ip></ip> <ip></ip> <ip></ip> <ip></ip> <ip></ip> </station17> </servers> '; my $xml = XMLin($str); print "$_\n" for @{ $xml->{station17}{ip} }; __END__
See also:

Replies are listed 'Best First'.
Re^2: Is there any XML reader like this?
by ashok.g (Beadle) on Jan 15, 2012 at 14:43 UTC

    I have been using your code and which uses Simple::XML but now I am unable to retrieve the "ip" with the same code:
    print "CMD:",@{ $xml->{$server}{ip} },"\n";
    This is printing nothing.

    And I have my XML file with server like:
    <station19> <ip></ip> </station19>
    Anything missing here?


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2016-10-21 18:42 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.