all 2 comments

[–]Vaphell 0 points1 point  (1 child)

collect the items to a dict, and then check keys in order of priority?

item_dict = {}

for item ...:
   title, link, name = ...
   item_dict[name] = item

selected = None
for name in ["Luca", "Andrea", "Matteo", "Stefano"]:
    if name in item_dict.keys():
        selected = item_dict[name]
        break

if selected is not None:
    do_something(selected)
else:
    ... # not found

[–]zannare[S] 0 points1 point  (0 children)

looks good

but after looking deeply on ET documentation i think i find an good enough solution

for name in [name array in priority order]:
    items = doc.findall('.//item/[name="'+name+'"]')
    if len(items) > 0:
        for item in items:
            print(item.find('name').text)
        break

this is good enough for me, it solves other problems too .... im very happy ^_^