<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Scriptico's Weblog</title>
	<atom:link href="http://scriptico.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://scriptico.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Fri, 30 Nov 2007 13:04:05 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>nl</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='scriptico.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/262609eb8c49be9d1055b346c78ffbf5?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Scriptico's Weblog</title>
		<link>http://scriptico.wordpress.com</link>
	</image>
			<item>
		<title>From non-RSS XML to PHP to HTML</title>
		<link>http://scriptico.wordpress.com/2007/11/20/from-non-rss-xml-to-php-to-html/</link>
		<comments>http://scriptico.wordpress.com/2007/11/20/from-non-rss-xml-to-php-to-html/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 22:52:25 +0000</pubDate>
		<dc:creator>scriptico</dc:creator>
				<category><![CDATA[scriptStuff]]></category>
		<category><![CDATA[affiliate]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[productfeed]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://scriptico.wordpress.com/2007/11/20/from-non-rss-xml-to-php-to-html/</guid>
		<description><![CDATA[What could be easier than having some info on, oh lets say&#8230;, interesting travels, dropped in a RSS feed, so anyone can include this info in their website. For example to, oh lets say&#8230; to get into an affiliate program. It could be easier, but it&#8217;s not. Today I got an XML which had to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scriptico.wordpress.com&blog=2163385&post=3&subd=scriptico&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>What could be easier than having some info on, oh lets say&#8230;, interesting travels, dropped in a RSS feed, so anyone can include this info in their website. For example to, oh lets say&#8230; to get into an affiliate program. It could be easier, but it&#8217;s not. Today I got an XML which had to be turned into some HTML for use on a travelling website. I was assuming it was plain RSS, so scripting something together within a few minutes would be no trouble at all. But upon checking the actual site URL I found that they&#8217;ve made stuff harder. Who needs standards? Just cook up yer own XML document!</p>
<p><span id="more-3"></span></p>
<p>So now I&#8217;m in the middle of getting this thing to work. I assumed the following steps were all it took:</p>
<ol>
<li>Download the file;</li>
<li>Parse the XML file into a multidimensional array structure;</li>
<li>Take every productitem and convert it to an object;</li>
<li>And drop every item into a nicely formatted HTML layout&#8230;</li>
<li>And perhaps introduce some caching of the XML file (since they do not change as often as a regular RSS feed)</li>
</ol>
<p>First I encountered a problem with getting the file to download (1). The PHP fopen() wrapper for remote urls was disabled at my shared host. Which is understandable and very common with shared hosting services. Fortunately, I was allowed to use the Curl library in PHP to retrieve the files. I coded the download, made a local file for caching purposes, and set up the XML parsing (2).</p>
<p>I wanted to parse the XML into a multidimensional array, as I find XML handling a little easier using arrays. I used a PHP class (clsParseXML.php by Eric Rosebrock from <a href="http://www.phpfreaks.com" target="_blank">www.phpfreaks.com</a>) to get this to work. Then I added a class productItem to map the XML structure into an object structure. And that should have done the trick.</p>
<p>Of course there were some setbacks. I developed the steps above and tested only with one feed. After placing the whole thing live, I found out that some feeds are simply huge. Two of them were just over 3 Mb in size. Downloading them to my site was no problem. But the PHP XML parsing failed miserably, due to lack of memory. I tried setting the memory limit up to 64 Mb, but no use. Apparently PHP isn&#8217;t really too happy about parsing large XML files. So I made up a little search-and-replace piece of code to get rid of any unwanted material, thereby reducing the file size&#8230; It&#8217;s still not really performing to the max, but I am getting there. All feeds I need to access can now be downloaded, cached, parsed and displayed the way I want.</p>
<p>I&#8217;m cleaning up the code now to get it online here.</p>
<p>It would be nice to develop this script a bit further to make it useful for other productfeeds.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/scriptico.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/scriptico.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scriptico.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scriptico.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scriptico.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scriptico.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scriptico.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scriptico.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scriptico.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scriptico.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scriptico.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scriptico.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scriptico.wordpress.com&blog=2163385&post=3&subd=scriptico&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://scriptico.wordpress.com/2007/11/20/from-non-rss-xml-to-php-to-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b92dcf908d4e1851739da40147e762a?s=96&#38;d=identicon" medium="image">
			<media:title type="html">scriptico</media:title>
		</media:content>
	</item>
		<item>
		<title>Safari and cross-domain cookies</title>
		<link>http://scriptico.wordpress.com/2007/11/20/hallo-wereld/</link>
		<comments>http://scriptico.wordpress.com/2007/11/20/hallo-wereld/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 12:55:05 +0000</pubDate>
		<dc:creator>scriptico</dc:creator>
				<category><![CDATA[scriptStuff]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[p3p]]></category>
		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Here&#8217;s one strange issue. I&#8217;ve got an IFRAME set up in a HTML page. The HTML page is located in one domain, and  the source (src) of the IFRAME is located in a second domain. This works fine in Firefox, however I ran into problems with several IE versions. Upon closer examination I noticed [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scriptico.wordpress.com&blog=2163385&post=1&subd=scriptico&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Here&#8217;s one strange issue. I&#8217;ve got an IFRAME set up in a HTML page. The HTML page is located in one domain, and  the source (src) of the IFRAME is located in a second domain. This works fine in Firefox, however I ran into problems with several IE versions. Upon closer examination I noticed the wonderful world of P3P: you need to include special P3P headers in the original HTTP request, in order to make this work. The cross-domain use of cookies is usually prohibited unless you include special headers. After adding a little line in my PHP code all was fine&#8230;<span id="more-1"></span></p>
<p><code>header("P3P:CP='IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT'");<br />
header("Location:index.php");<br />
exit();</code></p>
<p>That was all the header info IE needed. I&#8217;m not quite sure what this line meant, but hey, it worked. And in Firefox as well. In Safari however, there is no way to get cross-domain cookies to work. Not with the line above and not with any other Javascript-related workaround. But I am sure there must be a way to work around this. Or through this&#8230; Anyone?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/scriptico.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/scriptico.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/scriptico.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/scriptico.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/scriptico.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/scriptico.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/scriptico.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/scriptico.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/scriptico.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/scriptico.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/scriptico.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/scriptico.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=scriptico.wordpress.com&blog=2163385&post=1&subd=scriptico&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://scriptico.wordpress.com/2007/11/20/hallo-wereld/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b92dcf908d4e1851739da40147e762a?s=96&#38;d=identicon" medium="image">
			<media:title type="html">scriptico</media:title>
		</media:content>
	</item>
	</channel>
</rss>