<?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/"
	>

<channel>
	<title>blog.betabong.com &#187; xml</title>
	<atom:link href="http://blog.betabong.com/tag/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.betabong.com</link>
	<description></description>
	<lastBuildDate>Thu, 13 May 2010 09:49:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use GZip compression for your website</title>
		<link>http://blog.betabong.com/2010/03/25/use-gzip-compression-for-html-css-javascript-xml/</link>
		<comments>http://blog.betabong.com/2010/03/25/use-gzip-compression-for-html-css-javascript-xml/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 09:53:50 +0000</pubDate>
		<dc:creator>betabong</dc:creator>
				<category><![CDATA[Flash & more]]></category>
		<category><![CDATA[Browser]]></category>
		<category><![CDATA[Compression]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=316</guid>
		<description><![CDATA[Most of my Flash apps or websites use XML files, either for communication or initial data. They can get quite large, reaching about 100 kb or more is not seldom. You might say: so what?! 100 kb is like nothing for a bandwidth nowadays! Well, if you&#8217;ve every used iPhone tethering in an area where [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2009/03/05/javascript-canvas-3d/' rel='bookmark' title='Permanent Link: 3D Point Cloud with Javascript and Canvas'>3D Point Cloud with Javascript and Canvas</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Most of my Flash apps or websites use XML files, either for communication or initial data. They can get quite large, reaching about 100 kb or more is not seldom. You might say: so what?! 100 kb is like nothing for a bandwidth nowadays! Well, if you&#8217;ve every used iPhone tethering in an area where there is no 3g network, you start appreciating every single byte you won&#8217;t have to suck from the net. (On a side note: That&#8217;s when Opera really comes in handy.)</p>
<h3>XML files compress really well</h3>
<p>Because XML usually contains a lot of repetitive elements (noticably tags and attributes), they are like a compressor&#8217;s darling. Just zip a few of your XML files and you&#8217;ll see.</p>
<p>Now I kind of always thought that on nowadays webservers gzip compression is activated by default anyway. Which was wrong, at least for quite a bunch of servers I use.</p>
<h3>Activate GZip compression</h3>
<p>If your server installation contains the deflate module (which is the case for all of the ones I use), then you can simply add the following line to your .htaccess file:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># compress all html, plain text, xml, css and javascript:
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript</pre></div></div>

<p>AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript</p>
<div>I&#8217;ve also tried more complex constructs found on the web, but they resulted in «Internal server errors» which is why I&#8217;ll go along with this simple one for now.</div>
<div><strong><span style="font-weight: normal;">The effects are dramatic! I usually get about 70% – 80% of reduction for non-minimized files, </span></strong></div>
<div>
<h3>Examples</h3>
</div>
<div>
<table border="0" class="small">
<tbody>
<tr>
<th></th>
<th>Uncompressed</th>
<th>Compressed</th>
<th>Reduction</th>
</tr>
<tr>
<td><strong>Javascript minimized</strong><br />
<a href="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js">MooTools YUI compressed</a></td>
<td>66,867</td>
<td>20,964</td>
<td>68.6%</td>
</tr>
<tr>
<td><strong>Javascript minimized</strong><br />
<a href="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools.jss">MooTools uncompressed</a></td>
<td>102,991</td>
<td>27,599</td>
<td>73.2%</td>
</tr>
<tr>
<td><strong>XML/CSS combined</strong><br />
<a href="http://www.ceylor.ch/pages/home.xml">A larger initial XML file for a Flash website of mine</a></td>
<td>84,316</td>
<td>18,229</td>
<td>78.4%</td>
</tr>
<tr>
<td><strong>XML/CSS combined</strong><br />
<a href="http://www.ceylor.ch/pages/home.xml">A larger initial XML file for a Flash website of mine</a></td>
<td>84,316</td>
<td>18,229</td>
<td>78.4%</td>
</tr>
<tr>
<td><strong>HTML</strong><br />
<a href="http://20min.ch">A swiss news website, 20 Minuten</a></td>
<td>148,587</td>
<td>29,385</td>
<td>80.2%</td>
</tr>
<tr>
<td><strong>HTML</strong><br />
<a href="http://blog.betabong.com">My blogs home page</a></td>
<td>51,638</td>
<td>12,991</td>
<td>74.8%</td>
</tr>
</tbody>
</table>
<h3>Tools</h3>
<p>If you want to test your website, these pages are very informative (first one is faster, second one more informative):</p>
<p><a href="http://www.whatsmyip.org/http_compression/">http://www.whatsmyip.org/http_compression/</a></div>
<p><a href="http://www.gidnetwork.com/tools/gzip-test.php">http://www.gidnetwork.com/tools/gzip-test.php</a></p>
<p>I also like this one, although it only gives you little info on content-encoding. But very much on top of that :-)<br />
<a href="http://www.wmtips.com/tools/info/">http://www.wmtips.com/tools/info/</a></p>
<p>This little Firefox addon will tell you wether any site you visit has GZip activated:<br />
<a href="https://addons.mozilla.org/en-US/firefox/addon/54647">https://addons.mozilla.org/en-US/firefox/addon/54647</a> (Content Encoding Detector)</p>
<h3 style="font-size: 1.17em;">Conclusion</h3>
<p>HTML websites will profit a lot from this compression, as well as Flash sites (if just for your swfobject.js) that use textual communication. And best of all: it won&#8217;t need any kungfu effort on your side! And: practically all browsers support it. (I&#8217;ve only heard of problems with IE6, but then, you know, f*** IE6)</p>
<h3>Update:</h3>
<p>A more complete solution for your .htaccess file:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&lt;IfModule mod_deflate.c&gt;
	AddOutputFilterByType DEFLATE text/html
	AddOutputFilterByType DEFLATE text/xml
&nbsp;
	AddOutputFilterByType DEFLATE image/x-icon
&nbsp;
	AddOutputFilterByType DEFLATE text/css
&nbsp;
	AddOutputFilterByType DEFLATE text/javascript
	AddOutputFilterByType DEFLATE application/javascript
	AddOutputFilterByType DEFLATE application/x-javascript
	AddOutputFilterByType DEFLATE text/x-js
	AddOutputFilterByType DEFLATE text/ecmascript
	AddOutputFilterByType DEFLATE application/ecmascript
	AddOutputFilterByType DEFLATE text/vbscript
	AddOutputFilterByType DEFLATE text/fluffscript
&nbsp;
	AddOutputFilterByType DEFLATE image/svg+xml
	AddOutputFilterByType DEFLATE application/x-font-ttf
	AddOutputFilterByType DEFLATE application/x-font
	AddOutputFilterByType DEFLATE font/opentype
	AddOutputFilterByType DEFLATE font/otf
	AddOutputFilterByType DEFLATE font/ttf
	AddOutputFilterByType DEFLATE application/x-font-truetype
	AddOutputFilterByType DEFLATE application/x-font-opentype
	AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
	AddOutputFilterByType DEFLATE application/vnd.oasis.opendocument.formula-template
&lt;/IfModule&gt;</pre></div></div>

<p>(<a href="http://www.speedingupwebsite.com/2010/01/08/use-the-gzip-power/">Source</a>)</p>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2009/03/05/javascript-canvas-3d/' rel='bookmark' title='Permanent Link: 3D Point Cloud with Javascript and Canvas'>3D Point Cloud with Javascript and Canvas</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2010/03/25/use-gzip-compression-for-html-css-javascript-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>E4X String Parser</title>
		<link>http://blog.betabong.com/2008/09/23/e4x-string-parser/</link>
		<comments>http://blog.betabong.com/2008/09/23/e4x-string-parser/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 11:13:00 +0000</pubDate>
		<dc:creator>betabong</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[e4x]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[os]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=111</guid>
		<description><![CDATA[I did a lot of string parsing in the recent time: CSS Selectors, XML Display Objects, Stylesheets, &#8230; I also need XML selection from String expressions – I formerly (AS2) used the great XPath4AS2 from XFactorStudio which did it&#8217;s job well (though a bit slow, it&#8217;s AS2 after all).
There&#8217;s also one for Actionscript 3 (xpath-as3). [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2008/09/01/speed-parsing-string-in-as3/' rel='bookmark' title='Permanent Link: Simplicity follows Performance – parsing Strings in Actionscript 3'>Simplicity follows Performance – parsing Strings in Actionscript 3</a></li><li><a href='http://blog.betabong.com/2008/11/19/alchemy-release/' rel='bookmark' title='Permanent Link: Alchemy – THE cool new flash feature!'>Alchemy – THE cool new flash feature!</a></li><li><a href='http://blog.betabong.com/2008/07/21/nested-inner-functions-can-be-evil/' rel='bookmark' title='Permanent Link: Nested inner functions can be evil'>Nested inner functions can be evil</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I did a lot of string parsing in the recent time: CSS Selectors, XML Display Objects, Stylesheets, &#8230; I also need XML selection from String expressions – I formerly (AS2) used the great <a href="http://www.xfactorstudio.com/">XPath4AS2 from XFactorStudio</a> which did it&#8217;s job well (though a bit slow, it&#8217;s AS2 after all).</p>
<p>There&#8217;s also one for Actionscript 3 (<a href="http://code.google.com/p/xpath-as3/">xpath-as3</a>). But.. well&#8230; I wanted to go for some real speed! I like XPath a lot, but we now have native E4X selection in Actionscript 3, quite a different concept of node selection, and the conversion of XPath to E4X obviously results in quite a compromise in performance.</p>
<p>So all I need is a decent E4X parser. And hey, I found one! E<a href="http://www.adobe.com/devnet/flex/articles/e4x_print.html">4XParser from Digital Primates</a>. It does its job really well, especially considering the very compact code it consists of. Thanks to some preparsing and caching, it&#8217;s also quite fast.</p>
<p><strong>Still I thought I can do better :-)</strong> So I planted myself for a day (and a night) in front of my displays and hacked the hell out of it. The result is a little library which does pretty much the same thing as E4XParser, though pretty much more and a little faster too (15% to 50%). It&#8217;s about half as fast as the native E4X selection (once parsed). You can do nearly anything you can do with E4X. Use it like this:</p>
<p> </p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">betabong</span>.<span style="color: #0066CC;">xml</span>.<span style="color: #006600;">e4x</span>.<span style="color: #006600;">E4X</span>;
<span style="color: #000000; font-weight: bold;">var</span> result : XMLList = E4X.<span style="color: #006600;">evaluate</span><span style="color: #66cc66;">&#40;</span> xmllist , <span style="color: #ff0000;">&quot;author.( name.@last == 'Jobs' )&quot;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// E4X.evaluate( source : XMLList , expression : String ) : XMLList</span></pre></div></div>

<p> <br />
If your source is XML, just do XMLList( xml ), if your result should be xml, do xml = result[0]</p>
<p><a href="/showcase/e4x/E4X_Parse_Test.html">Test it here</a></p>
<p><a href="http://blog.betabong.com/showcase/e4x/E4X_Parse_Test.html" target="_blank"><img class="alignnone size-full wp-image-113" title="e4x" src="http://blog.betabong.com/wp-content/uploads/2008/09/e4x.png" alt="" width="512" height="405" /></a></p>
<p><strong>Restrictions:</strong> You can&#8217;t use AND/OR in comparisions. So, this won&#8217;t go: author.( name.@first == &#8216;Steve&#8217; &amp;&amp; name.@last == &#8216;Jobs&#8217; ) – though this is only a real limitations for OR. do this for AND: author.( name.@first == &#8216;Steve&#8217; ).( name.@last == &#8216;Jobs&#8217; ).</p>
<p><strong>What you can do:</strong> Yes, you can do quite advanced stuff like author.( name.@first == name.@last ) or car.@rating.average() (one of the few proprietary functions I added). Or even</p>
<pre>*..car.( @brand.toLowerCase() == 'volvo' ).( parent().( localName() == 'group' ).@rating &gt; @rating )</pre>
<p>– a weird example, I admit, but fancy, ain&#8217;t it? :-)</p>
<p>This is the first time ever I&#8217;m releasing part of my library as Open Source (MIT licence). As soon as I&#8217;ll find some time (and if I see any interest), I&#8217;m gonna put this into Google Code, so everybody can easily checkout and participate. Until then download it from here:</p>
<p><a class="download" href="/showcase/e4x/betabong-e4x.zip">Download</a> (zip 13kb)</p>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2008/09/01/speed-parsing-string-in-as3/' rel='bookmark' title='Permanent Link: Simplicity follows Performance – parsing Strings in Actionscript 3'>Simplicity follows Performance – parsing Strings in Actionscript 3</a></li><li><a href='http://blog.betabong.com/2008/11/19/alchemy-release/' rel='bookmark' title='Permanent Link: Alchemy – THE cool new flash feature!'>Alchemy – THE cool new flash feature!</a></li><li><a href='http://blog.betabong.com/2008/07/21/nested-inner-functions-can-be-evil/' rel='bookmark' title='Permanent Link: Nested inner functions can be evil'>Nested inner functions can be evil</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2008/09/23/e4x-string-parser/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
