« 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 | 8 Comments »
November 1st, 2024 at 20:59
… [Trackback]
[…] Read More Info here to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
November 13th, 2024 at 10:48
… [Trackback]
[…] Read More on to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
November 13th, 2024 at 20:49
… [Trackback]
[…] There you can find 74501 more Info to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
November 18th, 2024 at 21:35
… [Trackback]
[…] Information to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
November 19th, 2024 at 19:01
… [Trackback]
[…] Info to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
November 26th, 2024 at 16:27
… [Trackback]
[…] Find More Information here to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
November 28th, 2024 at 03:22
… [Trackback]
[…] Read More to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]
November 30th, 2024 at 20:05
… [Trackback]
[…] Find More to that Topic: compdigitec.com/labs/2009/12/26/free-and-open-source-xml-beautifers-to-format-xml/ […]