http://qs1969.pair.com?node_id=179548

c has asked for the wisdom of the Perl Monks concerning the following question:

I am using XML::Simple to parse a pretty non-complex xml file that deals with nodes on a network.

<network> <node name="edge1"> <community>something</community> <loopback>172.16.254.10</loopback> </node> <node name="edge2"> <community>anotherthing</community> <loopback>10.6.21.10</loopback> <loopback>10.12.71.14</loopback> </node> </network>

Now, I see how to grab the value of a field that has multiple choices. Such as edge2's loopbacks.

my $i =XMLin("xmlfile"); print "$i->{node}->{edge2}->{loopback}->[1]\n";
I have a decent idea of how to loop over all of the loopbacks for a given node, however how do I loop over all of the given nodes? Trying something like:

print "$i->{node}->[1]\n";
gives me an error saying that there is no reference to a hash. I can understand this error, but I'm not sure how to get past it to print out a list of all the known "nodes" in my xml file. My ultimate goal is to pass over the list of nodes and act upon then using the information held nested beneath them in the same xml file.

thanks -c