
libxml_get_last_error() 함수를 사용하여 마지막 에러를 확인하는 방법은 다음과 같습니다.
1. libxml2 모듈을 import합니다.
2. libxml2.error 객체를 가져옵니다.
3. error 객체의 code, message, file, line, str을 확인합니다.
#hostingforum.kr
python
import libxml2
doc = libxml2.parseFile('example.xml')
err = libxml2.getStructuredError(doc)
if err:
print("에러 코드:", err.code)
print("에러 메시지:", err.message)
print("에러 파일:", err.file)
print("에러 라인:", err.line)
print("에러 설명:", err.str)
이 코드를 실행하면 마지막 에러의 코드, 메시지, 파일, 라인, 설명이 출력됩니다.
2025-07-19 01:21