Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Calling nested containers with XML::Simple

by c (Hermit)
on Jul 05, 2002 at 07:06 UTC ( [id://179577]=note: print w/replies, xml ) Need Help??


in reply to Re: Calling nested containers with XML::Simple
in thread Calling nested containers with XML::Simple

Thanks! I agree that the second version is not very aesthetic whatsoever. I also found that when the containers are nested, they can be called via

$i->{snmp}{version}

i had been trying the syntax you show above with the second "->". i think that was the source of my frustration.

thanks again, your post helped very much. -c

Replies are listed 'Best First'.
(jeffa) 3Re: Calling nested containers with XML::Simple
by jeffa (Bishop) on Jul 05, 2002 at 15:51 UTC
    Whenever i use 'forcearray', i tend to loop:
    for my $snmp (@{$i->{snmp}}) { for my $version (@{$snmp->{version}}) { print "$version\n"; } }
    Now, consider XML::XPath, which 'drills down' to the nodes in question:
    use XML::XPath; my $xp = XML::XPath->new(filename => 'filename'); my $nodeset = $xp->find('global/snmp/version'); print $_->string_value, "\n" for $nodeset->get_nodelist;
    Much nicer. :)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2024-03-28 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found