develooper Front page | perl.beginners | Postings from June 2011

XML::Simple keyattr

From:
Jeffrey Joh
Date:
June 8, 2011 10:38
Subject:
XML::Simple keyattr
Message ID:
col101-w1447EC8507AE5C9E79655CC3620@phx.gbl





I have an issue with XML::simple keyattr.

I have two XML files:
calif.xml<result><Address><Homeid>123456</Homeid><State>California</State><City>San Francisco</City></Address><Address><Homeid>123457</Homeid><State>California</State><City>Los Angeles</City></Address></result>
texas.xml<result><Address><Homeid>123458</Homeid><State>Texas</State><City>Houston</City></Address></result>this file only has one address record.
When I use XML::Simple with the condition keyattr => {result -> address -> 'homeid'} then the first XML is hashed by homeid but the second XML file simply loses the homeid altogether.  I would like the key reference to exist, whether one or more than one key exists in a given file.  Can I force the keyattribute to be used?
 		 	   		  



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About