python string to xml
import xml.etree.ElementTree as ET
root = ET.fromstring(country_data_as_string)
python string to xml
import xml.etree.ElementTree as ET
root = ET.fromstring(country_data_as_string)
how to write pretty xml to a file python
# Use lxml as the core library for xml manipulation.
from lxml import etree
xml_object = etree.tostring(root,
pretty_print=True,
xml_declaration=True,
encoding='UTF-8')
with open("xmlfile.xml", "wb") as writter: # wb - write bytes mode
writter.write(xml_object)`
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us