Reading "Blog for America" on AvantGo

|

As a self-described Deaniac, I enjoy reading the Dean For America blog. However, while I can read it on my computer easily, there's been no AvantGo channel, and surfing the web on my Palm phone is somewhat slow and cumbersome. (I know; the world should have my problems.)

However, one can set up a custom channel on AvantGo quite easily, and there are RSS/XML feeds available from the blog. Combine these two things with readily available code to parse the feeds and translate them into HTML, and voila, instant mobile bliss.

So I got this script somewhere. Regrettably, I can't remember where so I can't credit the person or persons who created it, but I'm very grateful to whoever it was.

Anyway, here's the PHP code, modified for the blog. Enjoy!

<html>
<head>
<title>Blog For America</title>
</head>
<body>
<?php
$xmlfile =
fopen("http://blog.deanforamerica.com/index.xml","r");
if(!$xmlfile)die("cannot open the xml file");
$readfile = fread($xmlfile ,40000);
$searchfile = eregi("<item>(.*)</item>", $readfile ,$arrayreg);
$filechunks = explode("<item>", $arrayreg[0]);
$count = count($filechunks);
for($i=1 ; $i<=$count-1 ;$i++)
{
ereg("<title>(.*)</title>",$filechunks[$i], $title);
ereg("<description>(.*)</description>",$filechunks[$i], $description);
ereg("<link>(.*)</link>",$filechunks[$i], $links);
echo "<p>";
echo "<b>". $title[1]."</b>";
echo "<br />";
#For some reason, the xml feed has this weird CDATA tag in it, which keeps the
#text from displaying properly. The following two lines get rid of it. Hopefully it
#will get fixed soon!
$description[1]=str_replace("<![CDATA[","",$description[1]);
$description[1]=str_replace("]]>","",$description[1]);
echo $description[1];
echo "<a href ='".$links[1]."'\>".$links[1]."</a>";
#I added the following to lines so I could also have a link to the comments for
#each blog entry.
$comments[1]=str_replace(".html",".comments.html",$links[1]);
echo "| <a href='".$comments[1]."'\>Read comments</a>";
echo "</p>";
}
?>
</body>
</html>

Music I Listen To

 
Powered by Movable Type 4.2-en

Photos

Obama Purple. Playing. In the garden. Sun's up. Kitties!

About this Entry

This page contains a single entry by katherine published on November 28, 2003 7:29 PM.

Adelaide Herman Ellis, 1908-2003 was the previous entry in this blog.

Word. is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.