import re,sys,os K="말소등기전세권설정등기말소청구" def load(n): return open(f"tmp/{n}_{K}.xml",encoding='utf-8',errors='replace').read() def strip(s): s=re.sub(r'',r'\1',s,flags=re.S) s=re.sub(r'<[^>]+>','\n',s) return re.sub(r'\n{2,}','\n',s).strip() def arts(name, wanted): x=load(name) bi=re.search(r'<기본정보>(.*?)',x,re.S) if bi: b=bi.group(1) for t in ['법령명_한글','시행일자','공포일자','공포번호']: m=re.search(rf'<{t}>(?:)?',b,re.S) if m: print(f"[{name}] {t} = {m.group(1)}") for blk in re.findall(r'<조문단위[^>]*>.*?',x,re.S): m=re.search(r'<조문번호>(\d+)',blk) if not m: continue no=int(m.group(1)) g=re.search(r'<조문가지번호>(\d+)',blk) if no in wanted and not g: print("="*8, name, "제%d조"%no) print(strip(blk)[:2600])