Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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]
[Corion]: Discipulus: Better buy a new PC (well, self-build one from parts) than buy a new car :-)
[choroba]: the boot time on my laptops is more than satisfactory, but the desktop boots in 30+ secs
[choroba]: because of some problems of the wicked with systemd :-(
[Corion]: choroba: Just imagine how bad it must be without systemd ;-D
[choroba]: but I'm not sure it's worth my time...
NodeReaper shudders

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2017-07-27 09:14 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (407 votes). Check out past polls.