<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div><br></div><div><div><blockquote type="cite"><font class="Apple-style-span" color="#000000"><br></font>baoilleach wrote:<blockquote cite="mid:5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com" type="cite"><pre wrap="">If you are familiar with parsing XML, much of the data you need is
stored in the following file:
<a class="moz-txt-link-freetext" href="http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/elements/elements.xml?revision=34&content-type=text%2Fplain">http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/elements/elements.xml?revision=34&content-type=text%2Fplain</a>
</pre></blockquote></blockquote><div><br></div></div></div><div><br></div>Here's a quick BeautifulSoup script to read it into a python dict.  It misses anything not a scalar, but you can easily modify it to include arrays, etc... in the xml.<div><br></div><div><br></div><div>hope it's useful.  certainly a neat site!</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>bb</div><div><br></div><div><div><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Monaco; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>-- </div><div>Brian Blais</div><div><a href="mailto:bblais@bryant.edu">bblais@bryant.edu</a></div><div><a href="http://web.bryant.edu/~bblais">http://web.bryant.edu/~bblais</a></div><div><br class="khtml-block-placeholder"></div><br class="Apple-interchange-newline"></span> </div><div>from __future__ import with_statement</div><div>from BeautifulSoup import BeautifulSoup</div><div><br></div><div>with open('elements.xml') as fid:</div><div>    soup=BeautifulSoup(fid)</div><div>    </div><div>    </div><div>all_atoms=soup('atom')</div><div><br></div><div>element=soup('atom',{'id':'H'})[0]</div><div><br></div><div>elements={}</div><div>for atom in all_atoms:</div><div>    </div><div>    info={}</div><div>    id=atom['id']</div><div>    </div><div>    scalars=atom('scalar')</div><div>    </div><div>    for s in scalars:</div><div>        dictref=s['dictref']  # seems to have a bo at the beginning</div><div>        datatype=s['datatype'] # seems to have a xsd: at the beginning</div><div>        </div><div>        contents=s.contents[0]</div><div>        </div><div>        if datatype=='xsd:Integer':</div><div>            value=int(contents)</div><div>        elif datatype=='xsd:int':</div><div>            value=int(contents)</div><div>        elif datatype=='xsd:float':</div><div>            value=float(contents)</div><div>        else:</div><div>            value=contents</div><div>        </div><div>        </div><div>        key=dictref[3:]</div><div>        </div><div>        info[key]=value</div><div>    </div><div>    </div><div>    </div><div>    elements[id]=info</div><div>    </div><div><br></div></div></body></html>