onegative has asked for the wisdom of the Perl Monks concerning the following question:
# XML <AGENT hostname="viper3"> <LADDER> <ACL> <ACCOUNT id="4cf031986c"> <USERNAME>emcon</USERNAME> <HOST>*sppcon*</HOST> <PERMISSION>CDOPS</PERMISSION> </ACCOUNT> <ACCOUNT id="b92794bbd7"> <USERNAME>cpemcon</USERNAME> <HOST>*</HOST> <PERMISSION>COPS</PERMISSION> </ACCOUNT> <ACCOUNT id="8ff0478641"> <USERNAME>dbemcon</USERNAME> <HOST>*</HOST> <PERMISSION>COPS</PERMISSION> </ACCOUNT> <ACCOUNT id="22d2647740"> <USERNAME>tuxemcon</USERNAME> <HOST>*</HOST> <PERMISSION>COPS</PERMISSION> </ACCOUNT> </ACL> </LADDER> </AGENT>
# script use strict; use XML::Twig; my $file = $ARGV[0]; my $twig = XML::Twig->new(); $twig->parsefile($file); my $root = $twig->root; foreach my $acl ($root->children('ACL')){ print $acl->att('id'); print "\n"; print $acl->first_child('USERNAME'); print "\n"; print $acl->first_child('HOST'); print "\n"; print $acl->first_child('PERMISSION'); print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Twig Help
by toolic (Bishop) on Jan 07, 2011 at 14:13 UTC | |
by mirod (Canon) on Jan 07, 2011 at 14:35 UTC | |
by toolic (Bishop) on Jan 07, 2011 at 14:42 UTC | |
by onegative (Scribe) on Jan 07, 2011 at 17:08 UTC | |
by toolic (Bishop) on Jan 07, 2011 at 17:19 UTC | |
by onegative (Scribe) on Jan 10, 2011 at 21:31 UTC | |
by toolic (Bishop) on Jan 10, 2011 at 21:46 UTC | |
| |
|
Re: XML::Twig Help
by Gulliver (Monk) on Jan 07, 2011 at 14:33 UTC |