<?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>Brandon's Blog &#187; xml</title>
	<atom:link href="http://www.foszor.com/blog/tag/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.foszor.com/blog</link>
	<description></description>
	<lastBuildDate>Sat, 04 Sep 2010 22:36:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Server Logs: when XML and PHP have sex</title>
		<link>http://www.foszor.com/blog/2008/10/server-logs-when-xml-and-php-have-sex/</link>
		<comments>http://www.foszor.com/blog/2008/10/server-logs-when-xml-and-php-have-sex/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 18:02:34 +0000</pubDate>
		<dc:creator>brandon</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Website]]></category>
		<category><![CDATA[logs]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.foszor.com/blog/?p=62</guid>
		<description><![CDATA[My homey Chad has introduced me to the usage of XML. At first, I really didn&#8217;t know much about it besides the fact RSS feeds use it. But now the more I learn the more I love it. When we wrote the logs for Gear, we had a couple of choices. We could bloat a [...]]]></description>
			<content:encoded><![CDATA[<p>My homey Chad has introduced me to the usage of <a href="http://en.wikipedia.org/wiki/XML">XML</a>. At first, I really didn&#8217;t know much about it besides the fact RSS feeds use it. But now the more I learn the more I love it.</p>
<p>When we wrote the logs for Gear, we had a couple of choices. We could bloat a MySQL database with tons of log events, write it all to a flat file, or devise something new. Which chose the latter and our answer was XML. With the ability to store attributes and content, have parents and all sorts of hierarchy&#8230; its easily one of the best decisions we&#8217;ve made.</p>
<p>But when we get back to the topic of having the website and game servers talk, we run into a hiccup. All our events are stored in different sub tables; which means the log has a tables like &lt;chatlog&gt; and &lt;eventlog&gt;. Yeah that&#8217;s all fine and dandy, and we love how it turned out&#8230; but what happens when people want to view said logs? They aren&#8217;t shuffled together in chronological order&#8230; they&#8217;re all separate. <strong>SHIT FUCK DAMN!</strong></p>
<p>Putting them together in order wasn&#8217;t as easy as it should have been. Well actually I&#8217;m lying; it <em>was</em> easy once I figured out <em>how</em> to do it. That&#8217;s the thing about programming/scripting/developing custom shit: its not that the syntax or platform limits your ability to do something, or that it requires butt-loads of work&#8230; its being creative enough to figure out how to fucking do it. <strong>WHRY?!?</strong> Because not everything you want to do has been done by someone else in easy <a href="http://en.wikipedia.org/wiki/Copypasta">copypasta</a> format.</p>
<p><a href="http://www.foszor.com/blog/wp-content/uploads/2008/10/logs.png" class="highslide" onclick="return hs.expand(this)"><img src="http://www.foszor.com/blog/wp-content/uploads/2008/10/logs-150x150.png" alt="Server Logs" title="Server Logs" width="150" height="150" class="alignright size-thumbnail wp-image-69" /></a>When I started working on it I was looking for some PHP command that <a href="http://en.wiktionary.org/wiki/automagical">automagically</a> did it for me, and I think that was my problem. When trolling the PHP manual website and furiously searching Google for &#8220;put my XML in order&#8221; was no help, I decided to do it on my own.</p>
<p>Basically it came down to putting all the data into an array, and then sorting said array with the <a href="http://us3.php.net/usort">usort</a> function. <a href="http://www.youtube.com/watch?v=V0UNCnDTEBA">SUCCESS!</a></p>
<p>The only thing left was to display the data in a readable format. So mix in a tad of HTML, add a pinch of CSS&#8230; blend until sexy and you&#8217;ve got a finished product!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.foszor.com/blog/2008/10/server-logs-when-xml-and-php-have-sex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
