Quantcast

XML on OS X

Get the WebProNews Newsletter:
[ Social Media]

There aren’t many more computer acronyms more popular than XML. Go to the bookstore and check out the internet section-it’s all XML. What happened to plain old HTML? It’s old hat! Most people are probably wondering, “What can this XML thing do for me?”. Well basically for most of us, it saves us time. Lots of time.

Meet NetNewsWire Lite; it’s a lightweight cocoa application that you will soon fall in love with. What it does is take in XML feeds (in a flavor known as RSS or really simple syndication) from the sites you choose and display it in beautiful aqua. Sound lame? How about reading 30+ sites in under 10 minutes? Most of your favorite sites are available in RSS (Yes, even MacMerc) which makes scanning the Mac web a cinch. Want something besides Mac news? Well there are plenty of choices from all genres that can be added in just a few clicks right from NNW. Have a site you want to see a feed for, but can’t find one? Well there probably is one at NewsIsFree.com or Syndic8.com. Below is a screen shot of my set up, viewing MacMerc’s feed

If you still aren’t convinced consider the fact that Radio, Manilla, Movable Type, LiveJournal, Blogger, pMachine, Blosxom, PHPNuke, PostNuke and many more Content Management Systems all support RSS by default! That comes out to millions of sites that all support a technology that is almost unknown to anyone out of the closely knit blogosphere.

I improved the RSS support of MacMerc to include our story summaries (what you see on the front page) in the feed. That means right in NetNewsWire you can see if we’ve updated, read what the stories are about and choose what to read up on further. You can set NNW to update every 30 minutes which lets you keep up to date and still get work done :P. It’s got a dock icon that updates like Mail’s (a little red number showing the number of unread items).

Any site that updates daily and doesn’t support RSS should think about it. The easiest way to add support for your site is just to use one of the web publishing tools that support it to make your web site. That way you don’t have to sling code yourself. However, if you’re feeling lucky here is the format that your file should follow and a few pointers:

<?xml version="1.0" 
    encoding="ISO-8859-1" ?> 
<rss version="VERSION NUMBER">
<channel>
  <title>MacMerc.com - Start using RSS</title>
  <link>http://www.macmerc.com/rss</link>
  <description>You may already be a MacMerc!</description>
  <language>en-us</language>
<item>
  <title>This is the first story</title>
  <link>http://firstlink.com</link>
  <description>This is a description of the first item!</description>
</item>
</channel>
  </rss>

I added full RSS support to my AIM Quotes site by following the above format. It was such a simple script it only took a few minutes to code. I was even able to include the IM’s with their colors. To include HTML in your feed just convert the HTML to HTML entities. If you are writing in PHP (like I usually am) there is a function for this, htmlentities().

This is really basic as far as RSS is concerned but it shows the premises of what is going on. You’ll notice that it looks like HTML with different tags. That’s basically what it is, RSS just is a collection of standard tags. That’s how a reader like NetNewsWire can parse these files. Although this demo is really simple, you can do more advanced things with it such as including permanent links, copyright information, last build dates, and a ton of other information. To get the scoop check out UserLand’s RSS page. They are busy working on version 2.0 right now!

Tips for authoring:

  • Make sure to send the headers out as text/xml or your feeds will never work
  • Include new lines ( ) after each line
  • To speed things up author the xml file when things are published, not upon request (you’ll save a ton of CPU cycles)
  • Include a button on your web page that points to your feed, no one benefits from a secret feed
  • If you feel the need you can include advertising in the feeds, just add it to your code base. Most likely it won’t be effective but you never know.
  • If you don’t have a good statistical traffic monitor on your web server, build a counter into the file that is used to serve the XML. That way you’ll know if people are taking advantage of your feed.
  • Convert HTML to HTML Entities to make it work in your feeds.

Tips for using feeds:

  • Subscribe to LOTS of sites in the beginning, find out what you like after a few days. This is a good way to find new sites (NetNewsWire has a bunch of sites built in).
  • To add LiveJournals, just add /rss to the journal’s address. (http://www.livejournal.com/users/USERNAME/rss)
  • MacMerc is by default in the sites drawer of NetNewsWire but our syndication address is: http://www.macmerc.com/backend.php
  • MacMinute (our favorite Mac news site) has an unlinked feed: http://www.macminute.com/headlines.xml. This isn’t built into NetNewsWire yet so make sure to add this one ASAP!
  • MacUpdate (our favorite Mac Download site) has an OS X feed: http://www.macupdate.com/mommy/macsurferx.php. This isn’t built into NetNewsWire yet so make sure to add this one ASAP!

First appeared at MacMerc.com. Reprinted with permission from the author.

Jon Gales is a PHP consultant and internet publisher. He writes
Macintosh slanted content for both MacMerc.com and MacDesignOnline.com.
Jon publishes both MobileTracker.net and NewsIsCrappy.com. His personal
website is located at http://www.n3rd.net.

XML on OS X
Comments Off
Top Rated White Papers and Resources

Comments are closed.