Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by c (Hermit)
on Jul 05, 2002 at 07:06 UTC ( #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
Node Status?
node history
Node Type: note [id://179577]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2021-06-23 17:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (121 votes). Check out past polls.

    Notices?