Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55768
| From | Stefan Behnel <stefan_ml@behnel.de> |
|---|---|
| Subject | Re: XML to dict(d) |
| Date | 2011-01-31 14:08 +0100 |
| References | <4D46AF07.6000108@danielstender.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1498.1296479294.6505.python-list@python.org> (permalink) |
Daniel Stender, 31.01.2011 13:45: > 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? How do you want to the dict to look like? Stefan
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: XML to dict(d) Stefan Behnel <stefan_ml@behnel.de> - 2011-01-31 14:08 +0100
csiph-web