Monday, August 06, 2007 at 8:37 AM
Posted by Omar Khan, Software Engineer (Google Desktop Team)You love reading movie reviews and realize that Rotten Tomatoes, the movie review site, has an RSS feed. You think to yourself: Wouldn't it be great if I could use this RSS feed as part of my magical movie reviews gadget! It can't be hard to process an RSS feed, can it?
Well, RSS is an XML-based format. Many gadgets interact with XML data. They retrieve RSS/ATOM feeds or read in custom XML data from disk. Parsing this data isn't very difficult with JavaScript, but there are some challenges that developers often overlook. Specifically, XML can be malformed and thus can't be parsed. Also sometimes developers expect certain fields to be present when in fact they aren't. Each of these cases takes a small amount of handling, and that handling can greatly improve the robustness of your gadget in the face of XML from the web, which can, unfortunately, sometimes be rotten.
That's why I wrote a knowledge base article covering XML parsing. In it, we build a SimpleXmlParser class that I hope some of you will use in your future gadgets. Let us know what you think.
No comments:
Post a Comment