On 31 Mar 2006 at 9:39, Dave Adams wrote:

> How do I print the value of 'Time Magazine'?
> 
> Here is my file (ejournlist.xml):
> 
> <?xml version='1.0'?>
> <EJOURNLIST>
> <EJOURN>
>  <TI>Africa Confidential</TI>
>  <ISSUE>Vol. 1, no.1</ISSUE>
>  <FILEFORMAT>PDFformat</FILEFORMAT>
> </EJOURN>
> <EJOURN>
>  <TI>Time Magazine</TI>
>  <ISSUE>Vol. 1, no.1</ISSUE>
>  <FILEFORMAT>TXTformat</FILEFORMAT>
> </EJOURN>
> </EJOURNLIST>
> 
> Here is my script:
> 
> #!/usr/bin/perl -w
> use XML::Simple;
> use Data::Dumper;
> 
> #create object
> my $xml = new XML::Simple;
> 
> #read XML file
> my $data = $xml->XMLin("ejournlist.xml");
> 
> #print output
> print Dumper($data);
> 

my $i = $data->{EJOURN}->[1]->{TI};
                        ^                                       ^      ^
                hasref                          array Idx Tagname

print "Val=$i\n";

Don't know what they call the other one :(

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to