« Simple C++ gettext-like toolkit | Home | Windows SteadyState – a free DeepFreeze? »
Free and open source XML beautifers to format XML
By admin | December 26, 2009
XML is a great format for storing data, but an improperly-formatted XML file (e.g. whole file on one line, unusual breaking, improper line wrap, etc) can be just as difficult to read as a binary blob. In order to make “blob” XML readable, here are some tools you can use to format XML so it’s readable.
- A makeshift Python beautifier – A simple XML formattor written in Python, this formattor formats XML and actually works. Unfortunately, it formats <element>value</element> into
<element> value </element>
Which can actually decrease readability, especially if you have lots of short elements.
- HTML Tidy – Official HTML/XHTML formattor endorsed by the World Wide Web Consortorium. However the XML it formatted refused to contain indents, even after enabling all indenting and formatting options. It formatted <tag1><tag2><tag3>xyz</tag3></tag2></tag1> into
<tag1> <tag2> <tag3>xyz</tag3> </tag2> </tag1>
This is not much good since indents are generally required in human readable XML.
- PHP XML beautifier – Small PHP based XML beautifier. The only one that actually worked properly and formatted readable XML. Formatted <tag1><tag2><tag3>xyz</tag3></tag2></tag1> into
<tag1> <tag2> <tag3>xyz</tag3> </tag2> </tag1>
Which is the expected result. For more consistency, you might want to change (in BeautyXML.class.php)
var $how_to_ident = " "; // you can user also \t or more/less spaces
to
var $how_to_ident = "\t"; // you can user also \t or more/less spaces
to use tabs instead of spaces to save file space.
If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more interesting articles!
If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!
Topics: (X)HTML, Internet | 7 Comments »
June 27th, 2024 at 20:53
… [Trackback]
[…] Here you will find 75612 more Information to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
July 14th, 2024 at 17:46
… [Trackback]
[…] Read More on to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
July 20th, 2024 at 21:00
… [Trackback]
[…] Information to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
August 1st, 2024 at 17:27
… [Trackback]
[…] Info to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
August 10th, 2024 at 00:15
… [Trackback]
[…] Read More Info here on that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
September 2nd, 2024 at 19:16
… [Trackback]
[…] Here you will find 8943 additional Information on that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
September 14th, 2024 at 18:46
… [Trackback]
[…] Information to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]