Tired of screen-scraping your Daily Verse? Can’t wait to use XML instead? Well wait no longer as the good folks over at the International Bible Society recently began rendering their Daily Manna in a yummy variety of XML formats.
Unfortunately, they tried fitting a square peg into a round whole by delivering the goods using dated RSS 0.91 specification. I say unfortunately, because they were compelled to shove the link for the audio version of the daily verse into the /Channel/Description element, which in effect is adding an inner node. This means you get some unexpected results when using RSS parsing tools such as XML::RSS, as this inner node displays as Hash(0×12356) after the verse. In short, they’re offering an XML feed that doesn’t validate..
To get around this problem, I employed XML::Simple”>XML::Simple instead. Then I created the class ‘DailyManna‘ which parses the incoming rss stream into an easy to access and use object. Along the way, I customized some of the titles and the passage to fit my situation. Meaning, even though the IBS is now using RSS, they’re really not using it in a way that’s entirely friendly to those of us who want to control how the data looks and feels. Likewise, they fail to take advantage of the ability to list not only the current day’s verse, but those from the past week.
Over the weekend, I’m going to toy with creating an example of what I would prefer the IBS use, either via the RSS 2.0 and/or Atom. Please no RSS religious wars, though I would be interested in what you guys have to offer (i.e. examples) either way.
Until then, here is code to slice-n-dice the XML feed to your needs:
- Using your favorite editor, copy and paste the above code.
- Make sure you have installed LWP::Simple, XML::Simple and HTTP::Date
- chmod 755 DailyManna.pl (set permission)
- create an empty output file such as ‘DailyManna.pl’
- set the permissions of the target output file to 766 or 777
- run the script once from the shell – test for errors
- crontab to taste e.g.: crontab -e 0 2 * * * perl /path/DailyManna.pl>dailyManna.inc.php
- include the verse file in your documents
- edit your .css documents to accomodate the <div> containing the reference
- Leave comments if you’ve got improvements, and;
- please, give me time to make this a MovableType plug-in. I have plans of doing this, but I want to test the application, and get your opinions before I create the plug-in.