An ATOM file is type of XML file commonly used to publish news feeds (blogs, for example). But if you've ever looked at one, you know that you can't actually read them without some sort of translator. (Note: some browsers have a built-in atom reader, so if you actually can make sense out of that file, then view it's source to see what I am talking about.)
This script can be used to extract the information from an atom file and put it into four easy-to-use Javascript arrays.
You don't need to download anything! You can use the script right from my server. The address is 'http://stephengware.com/projects/atomjs/atomjs.php'. You'll need to pass one parameter to the script, namely the location of the atom file. To do this, just add '?url=' to the end of the address, and then the location of your file.
For example, if I have an atom file located at: http://stephengware.com/projects/atomjs/atomexample.xml (which I do), the link would be this:
Click on that link to see some example output. You'll want to view the source of the page, or else it won't make much more sense than the atom file. If you know Javascript (which I'll assume you do if you are using this script), you'll recognize that the information from the atom file has been neatly arranged into 4 arrays:
You can access these arrays from any Javascript on your page. For example, 'blogtitle[0]' is a string representing the title of the first post.
The best way to import a blog using my script is to include an external Javascript in your page. I highly recommend that you use both an opening and closing tag with nothing in between, because certain browsers have problems importing external scripts if you condense the tags into one tag with a '/>' ending. To import the above example:
<script type="text/javascript" ref="http://stephengware.com/projects/atomjs/atomjs.php?url=http://stephengware.com/projects/atomjs/atomexample.xml"></script>
Many blog services and news feeds publish atom files. I recommend Blogger.
If you find one, please e-mail me: sgware@gmail.com.
The PHP script and XSLT stylesheet are available here.