[ad_1]
I’m trying to parse this XML:
<dict>
<entry sk="maam: :5" eid="maam_e">
<indexer>
<seo>ma’am</seo>
<browse>
ma’am
<pos>noun</pos>
</browse>
<autocompletes>
<autocomp>ma’am</autocomp>
</autocompletes>
<indexing>
<arl type="headword">
<index>ma’am</index>
<display>
ma’am
<pos>noun</pos>
</display>
</arl>
</indexing>
</indexer>
<top-g eid="maam_topg_1">
<webtop>
<headword eid="maam_h_1">ma’am</headword>
<pos>noun</pos>
<pron-gs>
<phons_br geo="br" wd="ma'am">
<a class="uk_spkr.png">
<audio name="/m/ma/ma_/ma_am#1_gb_1" geo="br"/>
</a>
<phon>/mæm/</phon>
<pnc class="sep">,</pnc>
<a class="uk_spkr.png">
<audio name="/m/ma/ma_/ma_am#1_gb_2" geo="br"/>
</a>
<phon>/mɑːm/</phon>
</phons_br>
<phons_n_am geo="n_am" wd="ma'am">
<a class="us_spkr.png">
<audio name="/m/ma/ma_/ma_am#1_us_1" geo="n_am"/>
</a>
<phon>/mæm/</phon>
</phons_n_am>
</pron-gs>
</webtop>
<grammar>[singular]</grammar>
</top-g>
<sn-gs class="senses_multiple">
<sn-g sensenum="1" eid="maam_sng_1">
<sensetop>
<labels>(North American English)</labels>
</sensetop>
<sensebody>
<def>used as a polite way of addressing a woman</def>
<ul class="examples">
<li>
‘Can I help you, ma'am?’
<audio name="/_/_m/_ma/_ma_am#_gbs_1" geo="br"/>
<audio name="/_/_m/_ma/_ma_am#_uss_1" geo="n_am"/>
</li>
</ul>
<xr-gs xt="cp">
<pnc class="prefix">compare</pnc>
<xr-g href="sir_e" bord="n">
<xh>sir</xh>
</xr-g>
</xr-gs>
</sensebody>
</sn-g>
<sn-g sensenum="2" eid="maam_sng_2">
<sensetop>
<labels>(British English)</labels>
</sensetop>
<sensebody>
<def>used when addressing the Queen or senior women officers in the police or army</def>
</sensebody>
</sn-g>
<xr-gs xt="see">
<pnc class="prefix">see also</pnc>
<xr-g href="madam_e" bord="n">
<xh>madam</xh>
</xr-g>
</xr-gs>
<details id="maam_unbox_1" unbox="wordorigin" eid="maam_unbox_1">
<summary>Word Origin</summary>
<body>
<p>
mid 17th cent.: contraction of
<eb>madam</eb>
.
</p>
</body>
</details>
</sn-gs>
</entry>
</dict>
Basically, I have a dictionary saved in XML format. This is just a single entry.
I want to grab what is inside dict -> entry -> indexed -> SEO (at the very beginning of the code) and store it in a list, but I’m having a really hard time to parse this XML document.
I tried using etree but I’m still a noob when it comes to parsing.
Thanks for the help!
[ad_2]