import xml.dom.minidom
dom = xml.dom.minidom.parse(xml_fname) # or xml.dom.minidom.parseString(xml_string)
pretty_xml_as_string = dom.toprettyxml()
More Related Contents:
- How do I get Python’s ElementTree to pretty print to an XML file?
- Pretty print in lxml is failing when I add tags to a parsed tree
- Is there a built-in function to print all the current properties and values of an object?
- Converting XML to JSON using Python?
- How to convert an XML string to a dictionary?
- Print a list of space-separated elements
- How can this function be rewritten to implement OrderedDict? [duplicate]
- Can ElementTree be told to preserve the order of attributes?
- Pretty-print a NumPy array without scientific notation and with given precision
- How to create with Python’s cElementTree
- Python Requests package: Handling xml response
- How do I use a default namespace in an lxml xpath query?
- NumPy: Pretty print tabular data
- Switching into new window using Selenium after button click
- Python code to remove HTML tags from a string [duplicate]
- Python BeautifulSoup XML Parsing
- How can I convert XML into a Python object?
- Problem with newlines when I use toprettyxml()
- How can I access namespaced XML elements using BeautifulSoup?
- Simple CSV to XML Conversion – Python
- How to convert XML to JSON in Python? [duplicate]
- How can I output what SUDs is generating/receiving?
- Converting xml to dictionary using ElementTree
- Is there a way to get a line number from an ElementTree Element
- How to remove elements from XML using Python
- Find element by text with XPath in ElementTree
- Merge xml files with nested elements without external libraries
- Python xml ElementTree from a string source?
- Use xml.etree.ElementTree to print nicely formatted xml files [duplicate]
- ElementTree findall() returning empty list