On Friday, July 1, 2016 at 2:06:28 PM UTC-4, John Gordon wrote:
> In <3bbddafc-dcd6-4d5c-84f4-94077b5bc...@googlegroups.com> Basant Dagar 
> <dagar.basa...@gmail.com> writes:
> 
> > def lookup(d, keyval):
> >     found = False
> >     for child in d:
> >         if found : return child.text
> >         if child.tag == 'key' and child.text == keyval :
> >             found = True
> >     return None
> 
> > trackID = lookup(entry, 'Track ID')
> 
> > Below is the main part of input xml file data, it passes to lookup function:
> 
> > <key>Track ID</key><integer>369</integer>
> 
> > what I don't get is. How in the world it returns value 369 for the variable 
> > 'trackID'??
> 
> It loops through the child items in entry, looking for one with a
> 'key' value of 'Track ID'.  If it finds one, it sets found=True and
> loops one more time, returning the text of the *next* child element.
> 
> It depends on the 'key' element being directly followed by the 'integer'
> element within entry.
> 
> -- 
> John Gordon                   A is for Amy, who fell down the stairs
> gor...@panix.com              B is for Basil, assaulted by bears
>                                 -- Edward Gorey, "The Gashlycrumb Tinies"

Awesome. Thank you John for the prompt response.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to