This chapter covered a lot of ground, starting with a brief look at a basic web feed in RSS format. Now a little more familiar with the format of the feed, a more in-depth examination was undertaken, including a detailed examination of critical feed elements, as well as some tips to keep in mind when examining a feed for the first time. Retrieving feeds is all well and good, but it's impractical to do on page load, and as such the code required to store those feeds was presented, including some extensions to look at Atom feeds. Next, namespaced elements require some special code to be accessed with SimpleXML; the code required and some reasoning behind the namespacing was discussed. Consuming feeds and re-displaying their content is all well and good, but it can expose your site to security vulnerabilities, so methods of mitigating or lessening this risk were discussed. A less sinister but still worrisome problem is broken HTML in feeds. Using HTML Tidy resolves the problem nicely. Building on previous examples was a complete set of functions, designed to consume a feed and safely store it in a local database to be used in the next example. Finally, some possible uses for your retrieved feeds were suggested, along with some possible feed sources.
Overall, the major topics covered in this chapter were as follows:
Examining remote feeds, determining which elements are of particular use to your project
Retrieving remote feeds, including looking at the code, pulling it into a SimpleXML object, and caching a local copy
Dealing with namespaces in SimpleXML
Securing your feed handling
Handling broken HTML code within your feeds
Presenting your feeds to users
This chapter examined the processes involved in retrieving a feed presented elsewhere. The next chapter looks at things from the opposite perspective: how to present your data in a feed to others. The skills and knowledge you gained here will prove invaluable when developing your own feeds.