converting XML to hash/dict/CustomTreeCtrl

Stefan Behnel stefan_ml at behnel.de
Tue Feb 2 02:35:13 EST 2010


Astan Chee, 01.02.2010 23:34:
> I have xml files that I want to convert to a hash/dict and then further
> placed in a wx CustomTreeCtrl based on the structure. The problem I am
> having now is that the XML file is very unusual and there aren't any
> unique identifiers to be put in a dict and because there are no unique
> variables, finding the value of it from a CustromTreeCtrl is abit tricky.
> I would appreciate any help or links to projects similar to this.

What part of the structure and what information are you interested in? That
will determine the key that you should use. Maybe storing more than one
field as key is an option.

Stefan


> The XML file looks something like this:
> <doc>
> <rm:statsDoc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>    <stats name="position1" description="Calculation statistics"
> kind="position">
>    <stats name="time" description="Timing summary" kind="section">
>        <string name="timersNote" description="Note:">This is the note on
> calculation times</string>
>        <stats name="timers" kind="timers">
> 
>        <timer name="totaltime" description="Total time">
>            <elapsed>609.081574</elapsed>
>            <user>2531.972081</user>
>            <system>65.119100</system>
>        </timer>
>        <timer name="partialTimer" description="Gravitational Displacement">
>            <elapsed>1772.011230</elapsed>
>        </timer>
>        <stats name="subTimers" description="All non-phased time"
> kind="timers">
>            <timer name="subATimer" description="Phase time A">
>            <elapsed>72.418861</elapsed>
>            </timer>
> 
>            <timer name="subBTimer" description="Phase time B">
>            <elapsed>28.285192</elapsed>
>            </timer>
>            <timer name="spaceMem" description="Space memory">
>            <elapsed>0.000</elapsed>
>            </timer>
>        </stats>
>        <timer name="endTime" description="End">
>            <elapsed>607.432373</elapsed>
>        </timer>
>        </stats>
>    </stats>
>    <stats name="space" description="Space usage summary" kind="section">
>        <stats name="systemSpace" description="System Space">
>        <memory name="heapSpace" description="Total Space">
>            <peak>4833280000</peak>
> 
>            <current>4833280000</current>
>        </memory>
>        <memory name="spaceResidentSize" description="Space resident size">
>            <peak>4182777856</peak>
>            <current>4182777856</current>
>        </memory>
>        <int name="pageMem">1</int>
> 
>        <int name="memReclaims">1943498</int>
>        <int name="memSwaps">0</int>
>        </stats>
>        <stats name="subsystems" kind="memstats">
>        <memory name="geoSpace" description="Geo-Space">
>            <peak>1640100156</peak>
>            <current>411307840</current>
>        </memory>
>        <memory name="gridSpace" description="Grid-Space">
>            <peak>709596712</peak>
>            <current>1406752</current>
>        </memory>
>        <memory name="spaceMem" description="Space memory">
>            <peak>737720720</peak>
>            <current>0</current>
>        </memory>
>                <memory name="endTime" description="End">
>            <peak>607.432373</peak>
>        </memory>
>        </stats>
>            <memory name="subsystemSpace" description="Subsystem space
> total">
>        <peak>5164184694</peak>
>        <current>2054715622</current>
>        </memory>
> 
>    </stats>
>    </stats>
> </rm:statsDoc>
> </doc>
> 



More information about the Python-list mailing list