Answers for "create xml document in python"

0

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)`
Posted by: Guest on May-28-2021
0

python xml to html

<?xml version="1.0"?>
n
<html xmlns="http://www.w3.org/1999/xhtml">
  n
<head>
   <title>
   </title>
</head>
  n
<body>
  n
</body>
</html>
Posted by: Guest on August-06-2021

Python Answers by Framework

Browse Popular Code Answers by Language