ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
XML::Simple help
by Geek.Shrek other posts by this author
Aug 13 2009 6:31PM messages near this date
view in the new Beta List Site
Re: XML Parrot Was: XML::Rules tagspec | Re: XML::Simple help
& XSLT Hi,

I'm trying to extract an element value by using XML Simple

Here's my input xml


<Library> 
     <book> 
            <id> 1</id>
            <name> ABC</name>
     </book> 
     <book> 
            <id> 2</id>
            <name> ABC123</name>
     </book> 
     <book> 
            <id> 3</id>
            <name> ABCDEF</name>
     </book> 
</Library> 

I'm trying to get the name of id "1"


my $LibList = XMLin('library.xml', forcearray=> 1, keyattr => ['id']);

my $name = $LibList-> {'1'}->{name};
print "Customer id " . $name . "\n";

Can someone tell me what did I do wrong?

Thanks,



      __________________________________________________________________________________
Find local businesses and services in your area with Yahoo!7 Local.
Get started: http://local.yahoo.com.au
Thread:
Geek.Shrek
Jenda Krynicky
Terrence Brannon
Jenda Krynicky
Terrence Brannon
Jenda Krynicky
Grant McLean

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved