Posted by Shane O'Sullivan on October 7, 2011
If you’re a WebOS developer and would like to be able to notify your users when a new version of your app is available, a very efficient way to do that is to use the Yahoo Query Language.
Take a look at this page:
It shows a YQL query to select the version of the app com.chofter.palmdevutils, giving the following result
"p": "Version: 1.3.0"
Fetching this JSON object requires far less data that reading the entire HTML page and parsing it yourself. To see the final link that you would use, copy the link from the bottom of the Yahoo page, like this one http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22https%3A%2F%2Fdeveloper.palm.com%2Fappredirect%2F%3Fpackageid%3Dcom.chofter.palmdevutils%22%20and%0A%20%20%20%20%20%20xpath%3D’%2F%2Fdiv%5B%40id%3D%22app-price-system-version%22%5D%2Fp%5B3%5D’&format=json&callback=
Posted by Shane O'Sullivan on April 19, 2010
A quick little YQL tip. I recently had the need to count the number of items in an RSS feed, but without downloading the feed itself as the application is bandwidth sensitive. So I figured I’d use the Yahoo Query Language, which lets you define SQL queries for accessing all kinds of public data on the web, including of course RSS and Atom feeds.
However it’s implementation of the SQL count() function seems to be buggy, as you can’t simply do
select count(*) from xml where url=”http://path/To/Rss.xml” and and itemPath=”/rss/channel/item”
as it throws and error. Putting “item” in the count() doesn’t work either. However, if you try to select the text inside an element, it just returns a single text value, but you still get the count of rows returned, e.g.
select * from xml where url=”http://path/To/Rss.xml” and itemPath=”/rss/channel/item/title/text()”
returns JSON that looks like
"results": "5 stars by Anonymous on February 26, 2010"
meaning you save a huge amount of bandwidth but still can get the count of the items in the RSS stream. Check out an example HERE, just press the Test button. Cool huh?