Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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:

Comment on Re: Is there any XML reader like this?
Download Code
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 rifling through the Monastery: (5)
As of 2015-10-07 05:39 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (170 votes), past polls