<?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>klkl &#187; Pharmacy</title>
	<atom:link href="http://klkl.co.uk/category/pharmacy/feed/" rel="self" type="application/rss+xml" />
	<link>http://klkl.co.uk</link>
	<description>it's easy to type</description>
	<lastBuildDate>Tue, 11 Oct 2011 14:53:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP Equivalent to the SQL IN (&#8230;) Statement</title>
		<link>http://klkl.co.uk/2009/07/18/php-equivalent-to-the-sql-in-statement/</link>
		<comments>http://klkl.co.uk/2009/07/18/php-equivalent-to-the-sql-in-statement/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 13:21:28 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Pharmacy]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[dm+d]]></category>
		<category><![CDATA[NHS]]></category>
		<category><![CDATA[nhsbsa]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=203</guid>
		<description><![CDATA[<p>Recently I&#8217;ve been looking at using the NHS Business Service Authority&#8217;s Dictionary of Medicines and Devices for my own nefarious purposes. The Information (data that has meaning) is distributed as XML files.</p>
<p>I haven&#8217;t come across a database design for the data so I&#8217;ve come up with my own and to import the data into it I&#8217;ve been using PHP&#8217;s XML DOM functionality (<a title="Parse XML in PHP" href="http://klkl.co.uk/2007/10/23/how-to-parse-an-xml-file-using-php-part-1/" target="_blank">a different technique than I described in my earlier post &#8230;</a>). Because the files are published according to specified standards I decided to save myself some programming time by adopting their terminology for my database design so that I could write very little code to prepare the data and insert it into the database.</p>
<p>However, I wanted to test that the nodes I was expecting were what was being prepared for insertion into the database. One reason it may not is if the XML file has been reformatted with indents (<a title="HowTo Quickly Indent XML" href="http://klkl.co.uk/2009/07/14/how-to-indent-xml-quickly/" target="_blank">mentioned in this post</a>) What I needed was an equivalent to SQLs IN statement. The solution is to use PHP&#8217;s in_array() function like so&#8230;</p>
<p style="padding-left: 30px;"><strong>$desirable_values = array(&#8217;CD&#8217;, &#8216;CDDT&#8217;, &#8216;CDPREV&#8217;, &#8216;DESC&#8217;);<br />
if ( in_array( $variable_to_test, $desirable_values) ) {<br />
//Do Your Stuff<br />
}</strong></p>
<p>It saves you having to test if your variable is equal to each of the variables you want to test thus making your code cleaner and shorter.</p>
]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been looking at using the NHS Business Service Authority&#8217;s Dictionary of Medicines and Devices for my own nefarious purposes. The Information (data that has meaning) is distributed as XML files.</p>
<p>I haven&#8217;t come across a database design for the data so I&#8217;ve come up with my own and to import the data into it I&#8217;ve been using PHP&#8217;s XML DOM functionality (<a title="Parse XML in PHP" href="http://klkl.co.uk/2007/10/23/how-to-parse-an-xml-file-using-php-part-1/" target="_blank">a different technique than I described in my earlier post &#8230;</a>). Because the files are published according to specified standards I decided to save myself some programming time by adopting their terminology for my database design so that I could write very little code to prepare the data and insert it into the database.</p>
<p>However, I wanted to test that the nodes I was expecting were what was being prepared for insertion into the database. One reason it may not is if the XML file has been reformatted with indents (<a title="HowTo Quickly Indent XML" href="http://klkl.co.uk/2009/07/14/how-to-indent-xml-quickly/" target="_blank">mentioned in this post</a>) What I needed was an equivalent to SQLs IN statement. The solution is to use PHP&#8217;s in_array() function like so&#8230;</p>
<p style="padding-left: 30px;"><strong>$desirable_values = array(&#8217;CD&#8217;, &#8216;CDDT&#8217;, &#8216;CDPREV&#8217;, &#8216;DESC&#8217;);<br />
if ( in_array( $variable_to_test, $desirable_values) ) {<br />
//Do Your Stuff<br />
}</strong></p>
<p>It saves you having to test if your variable is equal to each of the variables you want to test thus making your code cleaner and shorter.</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2009/07/18/php-equivalent-to-the-sql-in-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Indent XML Quickly</title>
		<link>http://klkl.co.uk/2009/07/14/how-to-indent-xml-quickly/</link>
		<comments>http://klkl.co.uk/2009/07/14/how-to-indent-xml-quickly/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 19:42:51 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Pharmacy]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[dm+d]]></category>
		<category><![CDATA[indent]]></category>
		<category><![CDATA[libxml]]></category>
		<category><![CDATA[nhsbsa]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=189</guid>
		<description><![CDATA[<p>I&#8217;ve recently registered for accesss to the NHS&#8217;s dictionary of medicines and devices (dm+d). This was primarily to see what format the data was stored in and then to see if there was a way of utilising it in a cool webapp.</p>
<p>I downloaded the current release (its updated weekly) and unpacked the 5MB archive to reveal some XML and related files. Some of the files are huge (up to 32MB each and ~70MB in total) and there was no way a traditional program was going to mannage. I tried a few in fact and they all devastated my 2GB RAM and were generally unusable.</p>
<p>Time for a command line solution&#8230; VIM the open source text editor. Its extremely powerful and customisable but using it takes a little getting used to. VIM was able to open with only a slight delay and navigate these huge files. The next problem for me was being able to read them.</p>
<p>In theory it shouldn&#8217;t matter what indenting there is in an XML file as it doesn&#8217;t contain any data but I find its a lot easier to read the files if they&#8217;re &#8216;cleanly&#8217; indented. I began wondering how I was going to solve the problem and thought of a few ideas&#8230; a script (PERL, PHP, shell, other&#8230;) but none of those came to fruition. After some searching I came across <a href="http://xmlsoft.org/">libxml</a>.</p>
<p>You can download and compile from source if you wish but I decided to download a pre-built version from <a href="http://www.explain.com.au/oss/libxml2xslt.html">explain.com</a> it was pretty good and another page I came across on <a href="http://www.entropy.ch/blog/Developer/2008/04/23/XML-Pretty-Printing-in-BBEdit-and-vi-With-xmllint.html">entropy.ch</a> explained how to use it within Vim to indent my files super quick.</p>
<p>Here&#8217;s what you do&#8230;</p>
<ul>
<li>To format type this sequence
<ul>
<li>:%!xmllint &#8211;format -</li>
</ul>
</li>
<li>Or mark the area visually and then type
<ul>
<li>!xmllint &#8211;format -</li>
</ul>
</li>
</ul>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently registered for accesss to the NHS&#8217;s dictionary of medicines and devices (dm+d). This was primarily to see what format the data was stored in and then to see if there was a way of utilising it in a cool webapp.</p>
<p>I downloaded the current release (its updated weekly) and unpacked the 5MB archive to reveal some XML and related files. Some of the files are huge (up to 32MB each and ~70MB in total) and there was no way a traditional program was going to mannage. I tried a few in fact and they all devastated my 2GB RAM and were generally unusable.</p>
<p>Time for a command line solution&#8230; VIM the open source text editor. Its extremely powerful and customisable but using it takes a little getting used to. VIM was able to open with only a slight delay and navigate these huge files. The next problem for me was being able to read them.</p>
<p>In theory it shouldn&#8217;t matter what indenting there is in an XML file as it doesn&#8217;t contain any data but I find its a lot easier to read the files if they&#8217;re &#8216;cleanly&#8217; indented. I began wondering how I was going to solve the problem and thought of a few ideas&#8230; a script (PERL, PHP, shell, other&#8230;) but none of those came to fruition. After some searching I came across <a href="http://xmlsoft.org/">libxml</a>.</p>
<p>You can download and compile from source if you wish but I decided to download a pre-built version from <a href="http://www.explain.com.au/oss/libxml2xslt.html">explain.com</a> it was pretty good and another page I came across on <a href="http://www.entropy.ch/blog/Developer/2008/04/23/XML-Pretty-Printing-in-BBEdit-and-vi-With-xmllint.html">entropy.ch</a> explained how to use it within Vim to indent my files super quick.</p>
<p>Here&#8217;s what you do&#8230;</p>
<ul>
<li>To format type this sequence
<ul>
<li>:%!xmllint &#8211;format -</li>
</ul>
</li>
<li>Or mark the area visually and then type
<ul>
<li>!xmllint &#8211;format -</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2009/07/14/how-to-indent-xml-quickly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

