On 07/24/2006 04:59 PM, brian bwarn wrote:
I'm just starting out with XML::Simple and can't get
any output to display to STDOUT. What am I missing?
-------------------
Source XML snippet:
-------------------
> [snipped]
Use the ForceArray option to make traversal easier. Use
Data::Dumper to look at your data, then de-reference the right
things when you traverse:
# use modules
use XML::Simple;
use Data::Dumper;
# create object
$xml = new XML::Simple (KeyAttr=>[], ForceArray => 1);
# read XML file
$data=
$xml->XMLin("sp-includes.xml");
# dereference hash reference
# access <dataschemas> array
print "before loop ...\n";
foreach $d (@{$data->{dataschema}}) {
# print Dumper($d);
print "Dataschema: $d->{name}\n";
foreach my $inc (@{$d->{includes}[0]{include}}) {
print " Include: $inc->{name}\n";
}
}
print "finished\n";
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>