python - Return a parent tag attribute from selected child -


<tags>       <parent id="parent id">      <mid>       <child attr="child value" 

i have piece of code selecting attribute values xml correspond "child value".

i need have "parent value", relate 2 items, future use.

my code locates , retrieves child values, i'm having difficulty getting value parent id. correct syntax this?

currently code similar this:

taglist = [] parent in soup.find_all('tags'):     each in parent.find_all('child'):         taglist.append(repr(each['attr'])) 

i want retrieve, in example parent id value, child selected.

there relevant find_parent() method:

child.find_parent("parent", id=true)["id"] 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -