Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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]
[shmem]: LanX can get the logs from cbstream at any time from me.
shmem relocates to the pub over the street. Have a nice time.
[LanX]: well .. not so much interested in reading this article
[LanX]: my 2 cents: AngloZionistic sounds like an antisemtic theory, but to be critical of zionism doesn't mean to be anti-semitic
[shmem]: it hasn't been coined as a *mustread* without authority from the promoter
erix shoots an anti-bubble missile towards LanX
[LanX]: I don't have the time to go into depth of this blog though
[LanX]: anti-bubble missile?

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2018-03-19 21:35 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (246 votes). Check out past polls.