XML to dict(d)

D

Daniel Stender

Hi guys,

we are trying to convert a Sanskrit dictionary which is in a "homegrown" XML format into dict(d),
the input file goes like this:

<cut>
<H2><h><hc3>200</hc3><key1>akAlikam</key1><hc1>2</hc1><key2>a-kAlikam</key2></h><body>
<lex>ind.</lex> <c>immediately</c> <ls>MBh.</ls> </body><tail><mul/> <MW>000173</MW> <pc>2,2</pc>
<L>266</L></tail></H2>
<H2><h><hc3>110</hc3><key1>akAlya</key1><hc1>2</hc1><key2>a-kAlya</key2></h><body> <lex>mfn.</lex>
<c>unseasonable.</c> </body><tail><mul/> <MW>000174</MW> <pc>2,2</pc> <L>267</L></tail></H2>
<H1><h><hc3>110</hc3><key1>akAsAra</key1><hc1>1</hc1><key2>a-kAsAra</key2></h><body> <lex>m.</lex>
<c>N._of_a_teacher</c> <ls>BhP.</ls> </body><tail><mul/> <MW>000175</MW> <pc>2,2</pc>
<L>268</L></tail></H1>
<H1><h><hc3>110</hc3><key1>akiYcana</key1><hc1>1</hc1><key2>a-kiYcana</key2></h><body>
<lex>mfn.</lex> <c>without_anything_,_utterly_destitute</c> </body><tail><pc>2,2</pc>
<L>269</L></tail></H1>
<H1A><h><hc3>100</hc3><key1>akiYcana</key1><hc1>1</hc1><key2>a-kiYcana</key2></h><body> <lex
type="inh">mfn.</lex> <c>disinterested</c> </body><tail><pc>2,2</pc> <L>270</L></tail></H1A>
<H1B><h><hc3>110</hc3><key1>akiYcana</key1><hc1>1</hc1><key2>a-kiYcana</key2></h><body>
<lex>n.</lex> <c>that_which_is_worth_nothing.</c> </body><tail><MW>000176</MW> <pc>2,2</pc>
<L>271</L></tail></H1B>
<H3><h><hc3>110</hc3><key1>akiYcanatA</key1><hc1>3</hc1><key2>a-kiYcana--tA</key2></h><body>
<lex>f.</lex> <OR/>
<c>voluntary_poverty_<p>as_practised_by_<as0>Jaina</as0><as1><s>jEna</s></as1>_ascetics</p>.</c>
</body><tail><MW>000177</MW> <pc>2,2</pc> <L>272</L></tail></H3>
</cut>

I've found that there is the library python-dictdlib for concatenating dict dictionaries, what would
be the best way to "de-XML" the source file?

Thanks for any pointers in advance!

Daniel Stender
 
N

Neil Cerutti

Hi guys,

we are trying to convert a Sanskrit dictionary which is in a
"homegrown" XML format into dict(d), the input file goes like
this:

xml.etree.ElementTree will parse your file and return it as a
hierarchy of dict-like Element objects.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top