Thank you both for your replies. I'm still not having success with either Venkat's or Mumia's version of the foreach loop. I tried an example of something that should work--namely Listing C using the source in Listing A of the how-to article at http://builder.com.com/5100-6371-5363190.html.
I can't get anything to output with that either. Is there something I should look for in my configuration / module setup (I'm running perl v.5.6.1 (ActiveState Build 638) using the latest versions of XML-Simple and Data-Dumper provided at http://ppm.activestate.com/PPMPackages/zips/6xx-builds-only/. Thanks again, BW --- Venkat Saranathan <[EMAIL PROTECTED]> wrote: > The data structure is little more complicated than > list of hashes due to the > attributes in XML. > > > Here is an updated version of your perl code. > > #use modules > use XML::Simple; > use Data::Dumper; > > # create object > $xml = new XML::Simple (KeyAttr=>[]); > > # read XML file > > $data= > $xml->XMLin("C:\\temp\\input.xml"); > > # dereference hash reference > # access <dataschemas> array > > print "before loop ...\n"; > foreach $d > (@{$data->{dataschema}->{includes}->{include}}) { > print "in \$d loop ...\n"; > print $d->{name}, "\n"; > > } > print "finished\n"; > > > > with warm regards, > Venkat Saranathan > Gulf Breeze Software > www.gulfsoft.com > > GulfBreeze Blog > www.gulfsoft.com/blog > > > -----Original Message----- > From: brian bwarn [mailto:[EMAIL PROTECTED] > Sent: Monday, July 24, 2006 6:00 PM > To: beginners@perl.org > Subject: XML::Simple -- can't get anything to print > from array > > > 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: > ------------------- > <dataschemas> > <dataschema name="defaultDB"> > <includes> > <include name="Base Metadata"/> > <include name="Extracted Re-Map"/> > </includes> > <attributes> > <attribute category="" parser="TextParser" > extract="true" segmentation="soft"/> > </attributes> > </dataschema> > </dataschemas> > > --------------- > Perl code: > ---------------- > # use modules > use XML::Simple; > use Data::Dumper; > > # create object > $xml = new XML::Simple (KeyAttr=>[]); > > # read XML file > > $data= > $xml->XMLin("C:\datafiles\specialIncludes.xml"); > > # dereference hash reference > # access <dataschemas> array > > print "before loop ...\n"; > foreach $d (@{$data->{dataschema}}) { > print "in \$d loop ...\n"; > print "dataschema is: ", $d->{includes}->{name}, > "\n"; > } > print "finished\n"; > > --------------- > Output: > --------------- > before loop ... > finished > > Thanks, BW > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam > protection around > http://mail.yahoo.com > > -- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > <http://learn.perl.org/> > <http://learn.perl.org/first-response> > > > > > > -- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > <http://learn.perl.org/> > <http://learn.perl.org/first-response> > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>