import re,sys p="tmp/drf_말소등기전세권설정등기말소청구/L_채무자회생법.xml" s=open(p,encoding="utf-8").read() def cd(t): return re.sub(r'',r'\1',t,flags=re.S) m=re.search(r'<기본정보>(.*?)',s,re.S) b=cd(m.group(1)) for k in ["법령명_한글","시행일자","공포일자","공포번호","제개정구분명"]: mm=re.search(r'<%s>(.*?)'%(k,k),b,re.S) print(k,"=",mm.group(1).strip() if mm else None) units=re.findall(r'<조문단위[^>]*>.*?',s,re.S) print("조문단위수",len(units)) want={"제59조","제78조","제118조","제347조","제359조"} for u in units: n=re.search(r'<조문번호>(.*?)',u) num="제%s조"%n.group(1) if n else "?" if num in want: t=cd(u) t=re.sub(r'<[^>]+>','\n',t) t=re.sub(r'\n{2,}','\n',t).strip() eff=re.search(r'<조문시행일자>(.*?)',u) print("\n========== ",num," 조문시행일자=",eff.group(1) if eff else None) print(t[:2200])