Dear Perl community
I have to parse ID, TITLE and SYMBOL fields from the file below. In this
manner I wrote (modify actually) simple script to do that for me.
<?xml version='1.0'?>
<entries>
<entry>
<id>001</id>
<title>FIRST TITLE</title>
<symbol>SYMBOL AAA</symbol>
<symbol>SECOND CCC</symbol>
</entry>
<entry>
<id>002</id>
<title>SECOND TITLE</title>
<symbol>SYMBOL HHH</symbol>
</entry>
</entries>
Script below work well, if there is only one <symbol> field in each
entry. I have some troubles to implement second foreach structure to
loop through each symbol field and print it.
Thanks in advance for any help,
Andrej
-------------------------------------
#!/usr/bin/perl
# use module
use XML::Simple;
# create object
$xml = new XML::Simple (KeyAttr=>[]);
# read XML file
$data = $xml->XMLin("example.xml");
# access XML data
foreach $e (@{$data->{entry}}){
$id=$e->{id};
$title=$e->{title};
$symbol=$e->{symbol};
print "$id|$title|$symbol\n";
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>