import re from pathlib import Path xml = Path('exports/CRUSADER.EXE.xml').read_text(encoding='utf-8', errors='ignore') for m in re.finditer(r'