Assuming that there's only one row per version and you don't need the other versions at all you could create a function that parses the HTML and returns dict
representing version as soon as it's found. If version is not found it could return None
instead:
from xml.etree import ElementTree as ET
s = """
Release | REFDB | URL |
3.7.3 | 12345 | http://google.com |
3.7.4 | 456789 | http://foo.com |
"""
def find_version(ver):
table = ET.XML(s)
rows = iter(table)
headers = [col.text for col in next(rows)]
for row in rows:
values = [col.text for col in row]
out = dict(zip(headers, values))
if out['Release'] == ver:
return out
return None
res = find_version('3.7.3')
if res:
for x in res.items():
print(' - '.join(x))
else:
print 'Version not found'
Output:
Release - 3.7.3
URL - http://google.com
REFDB - 12345