Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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)`
Comment

PREVIOUS NEXT
Code Example
Python :: filter django or 
Python :: delay print in python 
Python :: how to loop through string in python 
Python :: python run in another thread decorator 
Python :: pretty size python 
Python :: convert csv file into python list 
Python :: set xlim histogram python 
Python :: draw circle pygame 
Python :: shift list python 
Python :: turn python script into exe 
Python :: print first word of a string python and return it 
Python :: string remove in python 
Python :: echo $pythonpath ubuntu set default 
Python :: timer 1hr 
Python :: string format zero padded int python 
Python :: pandas convert first row to header 
Python :: open excel through python 
Python :: python array methods 
Python :: run python script every hour 
Python :: subarray in python 
Python :: print from within funciton with multiprocessing 
Python :: Python string to var 
Python :: roblox api python 
Python :: cv2 blue color range 
Python :: Find unique values in all columns in Pandas DataFrame 
Python :: python variable declare 
Python :: what is *args and **kwargs in django 
Python :: how to stop a program after 1 second in python 
Python :: write cell output to file jupyter colab 
Python :: generate random integers in a range python 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =