I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2006-12-14 15:51:31-08 by mdd
problem parsing xml elements
I'm trying to parse and XML file, but i'm getting an unexpected result. Below is the orig xml and +the dump of the hash table <systems> <System id="48b2"> <SystemImageGUID>48b2</SystemImageGUID> <ConnectedNodes>1</ConnectedNodes> <Node id="nodeid1"> <NodeDesc>b2</NodeDesc> <NodeGUID>48b2</NodeGUID> </Node> </System> <System id="0101"> <SystemImageGUID>0101</SystemImageGUID> <ConnectedNodes>13</ConnectedNodes> <Node id="nodeid1"> <NodeDesc>Spine 1, Chip A</NodeDesc> <NodeGUID>1015b</NodeGUID> </Node> <Node id="nodeid2"> <NodeDesc>Spine 1, Chip A</NodeDesc> <NodeGUID>2015b</NodeGUID> </Node> </System> </systems> I'm just doing a straight XMLin(<filename>) to pull the file in and print Dump(xml) to get it back +out, the output looks like this: $VAR1 = { 'System' => [ { 'ConnectedNodes' => '1', 'Node' => { 'NodeDesc' => 'b2', 'id' => 'nodeid1', 'NodeGUID' => '48b2' }, 'SystemImageGUID' => '48b2', 'id' => '48b2' }, { 'ConnectedNodes' => '13', 'Node' => { '2015b' => { 'NodeDesc' => 'Spine 1, Chip A', 'id' => 'nodeid2' }, '1015b' => { 'NodeDesc' => 'Spine 1, Chip A', 'id' => 'nodeid1' } }, 'SystemImageGUID' => '0101', 'id' => '0101' } ] So, my question is home come on the first Node element since there is only one it does not list the + id field as an index like it did on the second set of Node elements? I realize there is only one + Node element in the first block, but i would have expected since there is an id attribute that it + would have made it a hash table like the second example. Thanks
Direct Responses: 3789 | Write a response
Posted on 2006-12-14 21:36:31-08 by grantm in response to 3776
Re: problem parsing xml elements

The ForceArray option is what you're looking for. This article should shed some light.

Direct Responses: Write a response