XML Formatter Pro

Related Pages: XML Minifier.

About XML Formatter Pro:

This pro online xml formatter tool helps you to format raw XML string so it can easily be read by human being.

This tool can force to format invalid XML String, even if the input String doesn't comply the official XML syntax properly.

The Advantages of XML over JSON:

XML is more extensible than JSON, XML can use tags and attributes to represent complex relationships within data.

XML is more widely used than JSON and has a longer history than JSON, HTML is also a kind of XML. It means XML data can be understand by more programmers.

comic xml formatter

More information about XML (Extensible Markup Language):

RFC 3470 (XML): https://tools.ietf.org/html/rfc3470

Python Implementation of XML (BeautifulSoup): https://www.crummy.com/software/BeautifulSoup/

Java Implementation of XML (dom4j): https://dom4j.github.io/

XML Formatter with Python (with package xml.dom):

from xml.dom import minidom

def format_xml(input_str):
    str = minidom.parseString(input_str)
    output_str = str.toprettyxml(indent="    ")
    return output_str

XML Formatter with Java (with package dom4j):

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;

public String Format(String xmlStr){
    Document document=DocumentHelper.parseText(xmlStr);
    OutputFormat format=OutputFormat.createPrettyPrint();
    StringWriter stringWriter=new StringWriter();
    XMLWriter writer=new XMLWriter(stringWriter,format);
    String resultStr=stringWriter.toString();
    return resultStr;