19 lines
417 B
Python
19 lines
417 B
Python
from ox.utils import ET
|
|
from lxml import etree
|
|
from StringIO import StringIO
|
|
|
|
def tostring(xml, doctype=None):
|
|
head = '<?xml version="1.0" encoding="UTF-8" ?>'
|
|
if doctype:
|
|
head += '\n' + doctype
|
|
else:
|
|
doctype = ''
|
|
|
|
x = etree.parse(StringIO(ET.tostring(xml)))
|
|
return head + '\n' \
|
|
+ etree.tostring(x, pretty_print=True)
|
|
|
|
return head + '\n' \
|
|
+ ET.tostring(xml)
|
|
|