while trying to study the article on perlmonks.org,
http://perlmonks.org/?node_id=490846
regarding XML parsing, I need bit of clarfication.
how do I parse out
<image src="http://www.oreilly.com/catalog/covers/perlbp.s.gif"
width="145" height="190" />
I tried $book->{image}->{src}... but doesn't work.. I need some
understanding on how these information is stored.
parsing code
use XML::Simple qw(:strict);
my $library = XMLin($filename,
ForceArray => 1,
KeyAttr => {},
);
foreach my $book (@{$library->{book}}) {
print $book->{title}->[0], "\n"
}
XML file
<library>
<book>
<title>Perl Best Practices</title>
<author>Damian Conway</author>
<isbn>0596001738</isbn>
<pages>542</pages>
<image src="http://www.oreilly.com/catalog/covers/perlbp.s.gif"
width="145" height="190" />
</book>
<book>
<title>Perl Cookbook, Second Edition</title>
<author>Tom Christiansen</author>
<author>Nathan Torkington</author>
<isbn>0596003137</isbn>
<pages>964</pages>
<image src="http://www.oreilly.com/catalog/covers/perlckbk2.s.gi
+f"
width="145" height="190" />
</book>
<book>
<title>Guitar for Dummies</title>
<author>Mark Phillips</author>
<author>John Chappell</author>
<isbn>076455106X</isbn>
<pages>392</pages>
<image src="http://media.wiley.com/product_data/coverImage/6X/07
+645510/076455106X.jpg"
width="100" height="125" />
</book>
</library>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/