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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -