import os
import xml.etree.ElementTree as ET

files = [
    r'C:\GESTIGEST\reportes\EtiquetaProducto.fr3',
    r'C:\GESTIGEST\reportes\EtiquetaProducto-GARRIGOS.fr3',
    r'C:\GESTIGEST\reportes\EtiquetaCaja.fr3',
    r'C:\GESTIGEST\reportes\EtiquetaCaja - GARRIGOS.fr3',
]

for f in files:
    if not os.path.exists(f):
        print("NOT FOUND:", f)
        continue
    print(f"\n==================== {os.path.basename(f)} ====================")
    try:
        tree = ET.parse(f)
        root = tree.getroot()
        for elem in root.iter():
            name = elem.attrib.get('Name', '')
            text = elem.attrib.get('Text', '')
            memo = elem.attrib.get('Memo.Utf8', '') or elem.attrib.get('Memo', '')
            tag = elem.tag
            
            # Print elements of interest
            if tag in ['TfrxMemoView', 'TfrxPictureView', 'TfrxRichView']:
                print(f"  Tag: {tag:18} Name: {name:25} Text: {repr(text[:50]) if text else ''} Memo: {repr(memo[:50]) if memo else ''} Field: {elem.attrib.get('DataField', '')}")
    except Exception as e:
        print("Error parsing:", e)
