<?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>Human Definition &#187; Code</title>
	<atom:link href="http://humandefinition.com/category/tutorials/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://humandefinition.com</link>
	<description>I design the web.</description>
	<lastBuildDate>Sat, 10 Jul 2010 08:05:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Parsing XML with PHP4 or PHP5</title>
		<link>http://humandefinition.com/tutorials/code/php-xml-parser/</link>
		<comments>http://humandefinition.com/tutorials/code/php-xml-parser/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 00:41:22 +0000</pubDate>
		<dc:creator>Josh Lee</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://humandef.com/php-xml-parser/</guid>
		<description><![CDATA[I recently had to make a player for theremnantmusic.com.  In it they wanted the song title to show up and change with each new song.

What was so hard about this was that the radio station was using an custom program made for them for their CCM radio station kduvfm.com.  So I had to [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p></p><p>I recently had to make a player for <a href="http://theremnantmusic.com">theremnantmusic.com</a>.  In it they wanted the song title to show up and change with each new song.<br />
<span id="more-81"></span><br />
What was so hard about this was that the radio station was using an custom program made for them for their CCM radio station kduvfm.com.  So I had to figure out how the heck I could get that program to convert the xml list and it just wasn&#8217;t happening.  Couldn&#8217;t get a hold of the dude who wrote the program because he has been shunned by the company he worked for at the time of making.</p>
<p>Being in a time crunch anyways I had my good friend from <a href="http://godbit.com/forum/profile.php?id=514">Godbit</a> forums Philip Schalm who slammed it out for me.  Basically it takes the xml file from where the radio stations server spits it out to on the ftp and then formats it for the web so I could manipulate it. Just put your variables in place of mine and you should be able to do whatever you want with it.</p>
<p>Here is an example of the xml file coming into the site.</p>
<pre>
&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
&lt;nexgen_audio_export&gt;
&lt;audio ID="id_1"&gt;
&lt;type&gt;Song&lt;/type&gt;
&lt;title&gt;Title:Reinventing Your Exit&lt;/title&gt;
&lt;artist&gt;By:Underoath&lt;/artist&gt;
&lt;/audio&gt;
&lt;/nexgen_audio_export&gt;
</pre>
<p>Here&#8217;s what the PHP4 script he came up with:</p>
<pre>
$xml = file_get_contents('PATHTOYOURXMLFILE.xml') or die("Can't open remote files!");
$arr = array();
$cur_tag = "";
function start_el_handler($parser,$name,$attribs) {
    global $cur_tag;
    $cur_tag = $name;
}
function end_el_handler($parser,$name){}
function char_handler($parser,$data) {
    global $cur_tag, $arr;
    $arr[$cur_tag] .= $data;
}
$parser = xml_parser_create();
xml_set_element_handler($parser, "start_el_handler", 'end_el_handler');
xml_set_character_data_handler($parser, "char_handler");
xml_parse($parser,$xml);
echo '&lt;ul id="ID-FOR-STYLING"&gt;';
  echo '&lt;li&gt; Artist: ' . preg_replace('/^By:?/','',$arr['ARTIST']) . '&lt;/li&gt;';
  echo '&lt;li&gt; Title: ' . preg_replace('/^Title:?/','',$arr['TITLE']) . '&lt;/li&gt;';
echo '&lt;/ul&gt;';
</pre>
<p>Phil&#8217;s note: The PHP4 method has some large disadvantages, namely that it can only parse a single &lt;audio&gt; at a time.  It&#8217;s not too difficult to hack on the ability to have multiple artists, but it&#8217;s more difficult to do it well and in a way that makes the script easy to modify for other uses.  Ultimately, though, you should use the awesome new PHP5 XML extensions (you are using PHP5, right?) as they make this kind of thing a lot easier.  What follows in a PHP5 example using the SimpleXML extension (and automatically allows multiple songs):</p>
<pre>
$xml = file_get_contents('PATHTOYOURXMLFILE.xml') or die("Can't open remote files!");
$xml = new SimpleXMLElement($xml);
echo '&lt;ul id="ID-FOR-STYLING"&gt;';
foreach ($xml->audio as $song) {
  echo '&lt;li&gt; Artist: ' . preg_replace('/^By:?/','',$song->artist) . '&lt;/li&gt;';
  echo '&lt;li&gt; Title: ' . preg_replace('/^Title:?/','',$song->title) . '&lt;/li&gt;';
}
echo '&lt;/ul&gt;';
</pre>
<p><script type="text/javascript" src="http://humandef.com/wp-content/themes/humandef/js/player.js"></script><br />
Hope this helps, <a href="JavaScript: openplayer('theremnant');">Click Here</a> to view player.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://humandefinition.com/tutorials/code/php-xml-parser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Listing blogroll links in a WordPress page or post</title>
		<link>http://humandefinition.com/tutorials/code/listing-blogroll-links-in-a-page-or-post/</link>
		<comments>http://humandefinition.com/tutorials/code/listing-blogroll-links-in-a-page-or-post/#comments</comments>
		<pubDate>Fri, 10 Aug 2007 21:20:01 +0000</pubDate>
		<dc:creator>Josh Lee</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://humandef.com/listing-blogroll-links-in-a-page-or-post/</guid>
		<description><![CDATA[I had been searching for about 2 hours, doing all manor or Google cursing trying to find a way to list a certain blogroll category in a page or post.  A site that i had made needed to have a list of artists it plays on the radio and have that list be link. [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p></p><p>I had been searching for about 2 hours, doing all manor or Google cursing trying to find a way to list a certain blogroll category in a page or post.  <a href="http://theremnantmusic.com">A site</a> that i had made needed to have a list of artists it plays on the radio and have that list be link.  Well, this is easily accomplished by having little monkeys enter in the info for you for every single artist and then updating that page on a whim, but we have no monkeys and it needed to be dynamic.<br />
<span id="more-80"></span><br />
So I came across some plugins but they were either outdated or really hard to use.  Then I stumbled upon <a href="http://www.websitehostingiq.net/about-website-hosting-iq/">Dominic Fosters</a> plugin to do this very thing.  Thank heavens, I was about to just go onto xbox live and slap some n00bs on swat. But I digress.<br />
This plug in is a breeze to use. it is called quite normally &#8220;<a href="http://www.websitehostingiq.net/blogroll-page-plugin/">Blogroll Page Plugin</a>&#8221; and it does just that.<br />
<br />
Couple of things I mod&#8217;d on this plug in were the actual category that it pulls up from my blogroll.<br />
Instead of having it automagically pull up the actual blogroll category of &#8216;2&#8242;, I changed it in the code towards the bottom where it says:<br />
<code>add_filter('the_content', 'bp_text', 2);</code><br />
was changed to reflect my certain category of &#8220;Artists&#8221; which had the number &#8216;11&#8242; associated with it.<br />
<code>add_filter('the_content', 'bp_text', 11);</code><br />
I only state this because there might be some of you who need to do this and this makes it easier to find and change to reflect your needs as well.<br />
View the page I used it on <a href="http://theremnantmusic.com/artists">here</a></p>
<p>Good job Dominic, good job.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://humandefinition.com/tutorials/code/listing-blogroll-links-in-a-page-or-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Help with WordPress E-Commerce Plugin</title>
		<link>http://humandefinition.com/tutorials/code/help-with-wordpress-e-commerce-plugin/</link>
		<comments>http://humandefinition.com/tutorials/code/help-with-wordpress-e-commerce-plugin/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 19:57:40 +0000</pubDate>
		<dc:creator>Josh Lee</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://localhost:8888/humandef/help-with-wordpress-e-commerce-plugin/</guid>
		<description><![CDATA[If you need help let me know, I now have it whipped into shape.


No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p></p><p>If you need help let me know, I now have it whipped into shape.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://humandefinition.com/tutorials/code/help-with-wordpress-e-commerce-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
