[kw-pm] Algorithm
Robert Pike
roberthpike at yahoo.com
Tue Jun 7 12:24:57 PDT 2011
Can anyone suggest the easiest / fastest way (with fewest lines of code) to take the xml below and create a hash with only the ids in the hash while preserving the hierarchy and using XML::Simple?
<!DOCTYPE TREELAYOUT [
<!ELEMENT treeMap (treeTop*)>
<!ELEMENT treeTop (blockInfo, treeTop*)>
<!ELEMENT blockInfo (id, name, description, field1)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT field1 (#PCDATA)>
]>
<?xml version="1.0" encoding="iso-8859-1"?>
<treeMap>
<treeTop>
<blockInfo>
<id>111</id>
<name>Item 111</name>
<description>Item Description</description>
<field1>Additional Info</field1>
</blockInfo>
<treeTop>
<blockInfo>
<id>111b</id>
<name>Item 111b</name>
<description>Item Description</description>
<field1>Additional Info</field1>
</blockInfo>
</treeTop>
<treeTop>
<blockInfo>
<id>222b</id>
<name>Item 222b</name>
<description>Item Description</description>
<field1>Additional Info</field1>
</blockInfo>
<treeTop>
<blockInfo>
<id>111c</id>
<name>Item 111c</name>
<description>Item Description</description>
<field1>Additional Info</field1>
</blockInfo>
</treeTop>
<treeTop>
<blockInfo>
<id>222c</id>
<name>Item 222c</name>
<description>Item Description</description>
<field1>Additional Info</field1>
</blockInfo>
</treeTop>
</treeTop>
<treeTop>
<blockInfo>
<id>333b</id>
<name>Item 333b</name>
<description>Item Description</description>
<field1>Additional Info</field1>
</blockInfo>
</treeTop>
</treeTop>
<treeTop>
<blockInfo>
<id>222</id>
<name>Item 222</name>
<description>Item Description</description>
<field1>Additional Info</field1>
</blockInfo>
</treeTop>
</treeMap>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/kw-pm/attachments/20110607/e7d9e292/attachment.html>
More information about the kw-pm
mailing list