|
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
|