Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Is there any XML reader like this?

by toolic (Chancellor)
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>10.0.0.101</ip> <ip>10.0.1.101</ip> <ip>10.0.0.102</ip> <ip>10.0.0.103</ip> <ip>10.0.1.103</ip> </station18> <station19> <ip>10.0.0.111</ip> <ip>10.0.1.111</ip> <ip>10.0.0.112</ip> <ip>10.0.0.113</ip> <ip>10.0.1.113</ip> </station19> <station17> <ip>10.0.0.121</ip> <ip>10.0.1.121</ip> <ip>10.0.0.122</ip> <ip>10.0.0.123</ip> <ip>10.0.1.123</ip> </station17> </servers> '; my $xml = XMLin($str); print "$_\n" for @{ $xml->{station17}{ip} }; __END__ 10.0.0.121 10.0.1.121 10.0.0.122 10.0.0.123 10.0.1.123
See also:


Comment on Re: Is there any XML reader like this?
Download Code
Re^2: Is there any XML reader like this?
by ashok.g (Beadle) on Jan 15, 2012 at 14:43 UTC
    toolic,

    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>10.0.1.113</ip> </station19>
    Anything missing here?

    Thanks,
    Ashok

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (19)
As of 2014-07-11 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (232 votes), past polls