FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


problem with hash from Perl XML::Simple





stone1343
Hi, I'm trying to use XML::Simple to parse an XML file (which happens to have genealogy data - generated by GED2XML)

I then use Data::Dumper to print everything, but I can't figure out where to go from here. It's not specific to XML::Simple, it's understanding hashes. I see this for one person, but can't figure out how to access it by ID, given that I don't know the IDs in advance. I even understand the structure: 'change', 'id' are keys.

I think part of what I don't understand is why am I using $data instead of %data, when it returns a hash? How can I traverse to find all the IDs of all the people, and work with them?

Hope the question & solution are clear enough to you...

Thanks

{
'change' => '2006-10-25T12:22:52',
'id' => 'P4',
'sex' => 'male',
'personalname' => {
'np' => [
{
'content' => 'George',
'tp' => 'unkw'
},
{
'content' => 'Bush',
'tp' => 'surn'
}
]
}
}

Here's the relevant code:

# create object
$xml = new XML::Simple(KeyAttr=>"");

# read XML file
$data = $xml->XMLin("jmsdown.gml");
print Dumper($data);

$people = $data->{person};
print Dumper($people);
Related topics
Theoretical Scientific Evidence For the Existence of God
Police that act like this need to be prosecuted.
Perhaps the US will finally learn...
The Middle East Conflict
Earn 100FRIH$ or more!!!
Scripting Language
Free web design services!
Is anything real?
javascript to open files
Feasability question
33 dead at Virginia Tech Shooting
windows xp home SP2 gr Activation Help
Problem with perl script
Is Youtube loosing it's mind?
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.