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
Re: simple XML::XPath question
by Yanick Champoux other posts by this author
Jul 13 2006 6:27PM messages near this date
view in the new Beta List Site
RE: simple XML::XPath question | Re: simple XML::XPath question
& XSLT On Thursday 13 July 2006 20:27, Lev Lvovsky wrote:
>  say that this is my xml file which I'd like to parse:
> 
>  <CompanyData>
>  <Owner>Joe Smith</Owner>
>  [..]
> 
>  What I'd like to do, is get all this stuff into a hash like this one:
> 
>  $DataList{first} = ("first_element1", "...", "...");
> 
>  Or perhaps a hash of hashes...


	Have you considered using XML::Simple? It's not XPath-based, but it seems to 
be doing exactly what you are looking for:

	use XML::Simple;
	use Data::Dumper;
	undef $/;

	my $parser = XML::Simple-> new;
	my $xml = $parser-> XMLin( <DATA>, KeyAttr => 'Id' );

	print Dumper( $xml );

	__DATA__
	<CompanyData> 
	<Owner> Joe Smith</Owner>
	...


Joy,
`/anick
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Lev Lvovsky
Mark - BLS CTR Thomas
Yanick Champoux
Lev Lvovsky

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