{"id":149,"date":"2009-12-26T09:07:55","date_gmt":"2009-12-26T14:07:55","guid":{"rendered":"http:\/\/www.compdigitec.com\/labs\/?p=149"},"modified":"2010-01-16T20:47:46","modified_gmt":"2010-01-17T01:47:46","slug":"free-and-open-source-xml-beautifers-to-format-xml","status":"publish","type":"post","link":"http:\/\/www.compdigitec.com\/labs\/2009\/12\/26\/free-and-open-source-xml-beautifers-to-format-xml\/","title":{"rendered":"Free and open source XML beautifers to format XML"},"content":{"rendered":"<p>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 &#8220;blob&#8221; XML readable, here are some tools you can use to format XML so it&#8217;s readable.<\/p>\n<ul>\n<li><a href=\"http:\/\/jyro.blogspot.com\/2009\/08\/makeshift-xml-beautifier-in-python.html\"><strong>A makeshift Python beautifier<\/strong><\/a> &#8211; A simple XML formattor written in Python, this formattor formats XML and actually works. Unfortunately, it formats &lt;element&gt;value&lt;\/element&gt; into\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;element&gt;\r\n    value\r\n&lt;\/element&gt;<\/pre>\n<p>Which can actually decrease readability, especially if you have lots of short elements.<\/li>\n<li><a href=\"http:\/\/tidy.sourceforge.net\/\"><strong>HTML Tidy<\/strong><\/a> &#8211; 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 &lt;tag1&gt;&lt;tag2&gt;&lt;tag3&gt;xyz&lt;\/tag3&gt;&lt;\/tag2&gt;&lt;\/tag1&gt; into\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;tag1&gt;\r\n&lt;tag2&gt;\r\n&lt;tag3&gt;xyz&lt;\/tag3&gt;\r\n&lt;\/tag2&gt;\r\n&lt;\/tag1&gt;<\/pre>\n<p>This is not much good since indents are generally required in human readable XML.<\/li>\n<li><a href=\"http:\/\/www.thedeveloperday.com\/xml-beautifier-tool\/\"><strong>PHP XML beautifier<\/strong><\/a> &#8211; Small PHP based XML beautifier. The only one that actually worked properly and formatted readable XML. Formatted &lt;tag1&gt;&lt;tag2&gt;&lt;tag3&gt;xyz&lt;\/tag3&gt;&lt;\/tag2&gt;&lt;\/tag1&gt; into\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;tag1&gt;\r\n    &lt;tag2&gt;\r\n        &lt;tag3&gt;xyz&lt;\/tag3&gt;\r\n    &lt;\/tag2&gt;\r\n&lt;\/tag1&gt;<\/pre>\n<p>Which is the expected result. For more consistency, you might want to change (in BeautyXML.class.php)<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">var $how_to_ident = &quot;\u00a0\u00a0\u00a0 &quot;; \/\/ you can user also \\t or more\/less spaces<\/pre>\n<p>to<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">var $how_to_ident = &quot;\\t&quot;; \/\/ you can user also \\t or more\/less spaces<\/pre>\n<p>to use tabs instead of spaces to save file space.<\/li>\n<\/ul>\n<p>If you found this article helpful or interesting, please help Compdigitec spread the word. Don\u2019t forget to <a title=\"Subscribe to Compdigitec Labs\" href=\"\/labs\/feed\/\">subscribe to Compdigitec Labs<\/a> for more interesting articles!<\/p>","protected":false},"excerpt":{"rendered":"<p>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 &#8220;blob&#8221; XML readable, here are some tools you can use to format XML so it&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[15,14],"tags":[34,627,160,196,625,626,624],"_links":{"self":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/149"}],"collection":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/comments?post=149"}],"version-history":[{"count":0,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/149\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/media?parent=149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/categories?post=149"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/tags?post=149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}