XML String to Dictionary

kimhyunchul·2021년 9월 28일
0
from lxml import etree


parser = etree.XMLParser(dtd_validation=True)

a = '<ACK ID="ENABLE_SEND_POG_RIGHT" STATE="1"'
try:
    b = etree.fromstring(a)
    print(b.tag) # ACK
    print(b.attrib) # {"ID":..., "STATE":...}
except:
    # When something goes wrong
    pass

0개의 댓글