python lxml loop on match get next entry

Multi tool use


python lxml loop on match get next entry
I'm using LXML to query multiple XML files containing data elements on various products. This section of code is taking a list of missing product_ids and querying the XML files for the data elements for the products.
One of my core issues is that every product_id obtained through xpath is checked against every item in the list products_missing_from_postgresql, which takes forever (hours)
How do I restart the for entry in entries loop when a match is found?
Maybe this isn't the right question...if not what is the right question?
for product_number in products_missing_from_postgresql:
try:
for entry in entries:
product_id = entry.xpath('@id')[0]
if product_id != product_number:
print('************************')
print('current product: ' + product_id)
print('no match: ' + product_number)
print('************************')
else:
print('************************')
print('************************')
print('product to match: ' + product_number)
print('matched from entry: ' + product_id)
print('************************')
print('************************')
Code output:
************************
************************
product to match: B3F2H-STH
matched from entry: B3F2H-STH
************************
************************
************************
current product: B3F2H-STL
no match: B3F2H-STH
************************
************************
current product: B3F2H-004
no match: B3F2H-STH
************************
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.