On Fri, 2006-31-03 at 15:42 -0500, Dave Adams wrote:
> I am trying to get the number of children of the root element and my script
> gives me the number of children of the children instead.
>
> Here is my XML document (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 perl script:
>
> #!/usr/bin/perl -w
> use XML::Simple;
> #create object
> my $xml = new XML::Simple;
>
> #read XML file
> my $data = $xml->XMLin("ejournlist.xml");
>
> my $ejourn_cnt = scalar(keys %{$data->{'EJOURN'}});
# What happens when you do this?
my $ejourn_cnt = scalar(keys %{$data->{'EJOURNLIST'}});
> print "The number of EJOURNs is: $ejourn_cnt \n";
>
> *The scripts returns 3 when it should return 2.*
>
> Any advice would be appreciated.
>
> DA
>
> **
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>