<?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>Remaining Relevant &#187; css</title>
	<atom:link href="http://remainingrelevant.net/remaining/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>http://remainingrelevant.net</link>
	<description>Why stop dreaming when you wake up?</description>
	<lastBuildDate>Tue, 24 Aug 2010 11:38:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Adventures in xml</title>
		<link>http://remainingrelevant.net/remaining/90</link>
		<comments>http://remainingrelevant.net/remaining/90#comments</comments>
		<pubDate>Thu, 26 Jan 2006 19:39:52 +0000</pubDate>
		<dc:creator>Lichen Rancourt</dc:creator>
				<category><![CDATA[Libraries, Services, and Librarians]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://localhost/remainingrelevant/?p=90</guid>
		<description><![CDATA[I live in a coding netherworld. Given instructions, I can write code. Given code, I can usually happily change it to meet my needs. I understand most languages, intellectually, but I do not speak them. So when I want to do something, know it can be done but don&#8217;t know how to do it, I [...]]]></description>
			<content:encoded><![CDATA[<p>I live in a coding netherworld.  Given instructions, I can write code.  Given code, I can usually happily change it to meet my needs.  I understand most languages, intellectually, but I do not speak them.   So when I want to do something, know it can be done but don&#8217;t know how to do  it, I am further dogged by rarely being able to effectively communicate the need to either a search or a person who I know has the answer.  Over time this has produced quite a lot of anxiety and frustration.  I am, nevertheless, intrepid and tend to barge ahead &#8211; ignorance is so often bliss.  The most recent of these forays involves xml and rss.</p>
<p><span id="more-90"></span><br />
We have a <a href="http://www.library.unh.edu/news/index.shtml">library news page</a>, which is completely hand coded.   I wanted to generate an rss feed for the content, but then repurpose the feed to also generate the news page archive.  Since the content is not database generated, I only want to enter it once.   My understanding of xml is that it renders content portable and this should be easy.</p>
<p>I started with the feed itself.  With a quick search and <a href="http://www.cybertechhelp.com/tutorial/article/creating-an-rss-feed-basics">some</a> <a href="http://www.mnot.net/rss/tutorial/">instructions</a> it was up and running in no time.  I was jublilant.  I then turned my attention toward importing the xml content into my page.  &#8220;Xml makes content portable,&#8221; I thought to myself, &#8220;this should be a snap.&#8221;  All I need to do is associate the html page with the xml page, map the tags together, and off I go.  It is not that easy.  <a href="http://www.w3.org/Style/styling-XML">CSS</a> didn&#8217;t do it there was too much else included on the pages. I need to get the xml into the html (layout), not apply layout (css) to xml.  XSLT seemed too much for such a simple (although gaining complications by the minute) project.  Do I write a <a href="http://www.w3schools.com/dtd/dtd_intro.asp">DTD</a>?  That seemed <a href="http://www.w3.org/Style/customdtd">ill advised</a>.  I found some promising stuff about <a href="http://www.w3schools.com/xml/xml_data_island.asp">Data Islands and data binding</a> seems perfectly logical&#8230; but I was horrified to learn that it only works with <a href="http://www.microsoft.com/windows/ie/default.mspx">Internet Explorer</a>.  Exasperated, deflated, and complemplating resignation, I turned to <a href="http://www.maisonbisson.com">my interpreter</a>, who delivered a shattering blow, &#8220;huh, I don&#8217;t know if you can do that.&#8221;  Being the helpful chap he is, <a href="http://www.maisonbisson.com">Casey</a> sent me a couple javascript solutions: a <a href="http://script.aculo.us/">Script.aculo.us</a> (you can learn some AJAX, he encouraged&#8230; I&#8217;d had enough learning for one day) and <a href="http://jade.mcli.dist.maricopa.edu/feed/">Feed to javascript</a>.  I&#8217;m ashamed to say that his kind help was met only with my righteous indignation &#8211; this should be easy!</p>
<p>Defeated, I went to the gym to deflate.  I returned the next day to an email from <a href="www.maisonbisson.com">Casey</a> (aka, my hero) with a tidy little php function designed to parse out the xml and deliver me the pieces to do with what I want.  I changed it a bit to fine tune and, must admit, that I think it&#8217;s brilliant.<br />
<code><br />
function rssrenderer($feed, $count=50) {</p>
<p>	// fetch the RSS feed<br />
	$xmlraw = utf8_encode(file_get_contents($feed));</p>
<p>	// parse it<br />
	$xml = simplexml_load_string($xmlraw);</p>
<p>	// read through each item and render it<br />
	$i = 1;<br />
	foreach ($xml->channel->item as $item) {</p>
<p>	if($i > $count) break;<br />
		$i++;</p>
<p>		$title = ($item->title);<br />
		$link = ($item->link);<br />
		$date = ($item->pubDate);</p>
<p>		echo "&lt;a href=\"$link\"&gt;$title &lt;br /&gt;&lt;i&gt;Posted on $date&lt;/i&gt;";<br />
		}<br />
	}<br />
</code></p>
<p>I then called it up in the right moment on my display page and, viola, worked like a charm.  Easily reused, too, for other feeds.  Here&#8217;s the <a href="http://www.library.unh.edu/news/index.php">xml-generated page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://remainingrelevant.net/remaining/90/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
