<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Magp.ie &#187; UNIX Script</title>
	<atom:link href="http://magp.ie/tag/unix-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://magp.ie</link>
	<description>A nest for the random, shiny, online tidbits I stumble across...</description>
	<lastBuildDate>Wed, 16 May 2012 09:40:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='magp.ie' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/061e340c5da13b5a41ae8016bee03aa8?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Magp.ie &#187; UNIX Script</title>
		<link>http://magp.ie</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://magp.ie/osd.xml" title="Magp.ie" />
	<atom:link rel='hub' href='http://magp.ie/?pushpress=hub'/>
		<item>
		<title>Format XML with TextWrangler</title>
		<link>http://magp.ie/2010/02/15/format-xml-with-textwrangler/</link>
		<comments>http://magp.ie/2010/02/15/format-xml-with-textwrangler/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 20:47:06 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Shortcuts]]></category>
		<category><![CDATA[format xml]]></category>
		<category><![CDATA[textwrangler]]></category>
		<category><![CDATA[UNIX Script]]></category>

		<guid isPermaLink="false">http://blogalhost.wordpress.com/?p=97</guid>
		<description><![CDATA[My text editor of choice on the Mac is TextWrangler. It&#8217;s lightweight and it has pretty much all you need from a text editor. In particular, I like that I can SFTP into my development server. One issue that bugged &#8230; <a href="http://magp.ie/2010/02/15/format-xml-with-textwrangler/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&#038;blog=11708208&#038;post=97&#038;subd=blogalhost&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My text editor of choice on the Mac is <a href="http://www.barebones.com/products/TextWrangler/" target="_blank">TextWrangler</a>. It&#8217;s lightweight and it has pretty much all you need from a text editor. In particular, I like that I can SFTP into my development server.</p>
<p>One issue that bugged me lately was when I opened an <em>unindented</em>, <em>unformatted</em> XML file. Basically, it looked a mess and there was no way to tidy the file up so that I could read it easily.</p>
<p>However, I found a simple way to do this today&#8230; <span id="more-97"></span>thanks to <a href="http://groups.google.com/group/textwrangler/browse_thread/thread/ea4d509c9266a6b1" target="_blank">this</a> and <a href="http://www.entropy.ch/blog/Developer/2008/04/23/XML-Pretty-Printing-in-BBEdit-and-vi-With-xmllint.html" target="_blank">this</a>.</p>
<p><strong>Simple guide</strong><br />
We want to add a UNIX script to TextWrangler so it can format an XML file&#8230; to do this, do this&#8230;</p>
<ul>
<li>Open TextWrangler and open a new text file.</li>
<li>Copy and paste the code below into this file.</li>
<p><pre class="brush: plain;">
#!/bin/sh
xmllint --c14n &quot;$*&quot; | XMLLINT_INDENT=$'\t' xmllint --encode UTF-8 --format -
</pre></p>
<li>Save the file, something like <strong>Tidy XML.sh</strong>, in the Filters folder.</li>
<li>You can find the filters folder by going to the <em>#! menu</em> and go to the <em>Unix Filters</em> sub-menu, and select the <em>Open Filters Folder</em>, like below.
<ul><img class="alignnone size-full wp-image-98" title="Scripts menu" src="http://blogalhost.files.wordpress.com/2010/02/picture-7.png?w=450" alt=""   /></p>
<li>Now anytime you want to format an XML file, just go to this menu and select the <strong>Tidy XML.sh</strong> script and BOOM, neat tidy XML.</li>
<p><img class="alignnone size-full wp-image-99" title="Select Script" src="http://blogalhost.files.wordpress.com/2010/02/picture-8.png?w=450" alt=""   /></ul>
</li>
</ul>
<p>This is an interesting facility to extend an already great text editor, and I will be looking into more cool scripts that can hopefully lessen my daily annoyances.</p>
<p><em><strong>UPDATED</strong>:: Added UTF8 encoding, thanks Rolan.</em><br />
<em><strong>UPDATED</strong>:: Added a post to <a href="http://wp.me/pN7Q4-72">format PHP code</a> in TextWrangler.</em></p>
<br />Filed under: <a href='http://magp.ie/category/shortcuts/'>Shortcuts</a> Tagged: <a href='http://magp.ie/tag/format-xml/'>format xml</a>, <a href='http://magp.ie/tag/textwrangler/'>textwrangler</a>, <a href='http://magp.ie/tag/unix-script/'>UNIX Script</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/97/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&#038;blog=11708208&#038;post=97&#038;subd=blogalhost&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2010/02/15/format-xml-with-textwrangler/feed/</wfw:commentRss>
		<slash:comments>50</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>

		<media:content url="http://blogalhost.files.wordpress.com/2010/02/picture-7.png" medium="image">
			<media:title type="html">Scripts menu</media:title>
		</media:content>

		<media:content url="http://blogalhost.files.wordpress.com/2010/02/picture-8.png" medium="image">
			<media:title type="html">Select Script</media:title>
		</media:content>
	</item>
	</channel>
</rss>
