Weather XML code


SUBMITTED BY: rajesh93

DATE: Feb. 16, 2017, 9:54 a.m.

FORMAT: Text only

SIZE: 512 Bytes

HITS: 965

  1. local lom = require 'lxp.lom'
  2. local xpath = require 'xpath'
  3. local response = http.request {
  4. -- 12798885 is the "WOEID" for Bellevue, WA
  5. url = 'https://query.yahooapis.com/v1/public/yql',
  6. params = {
  7. q = 'select * from weather.forecast where woeid=12798885'
  8. }
  9. }
  10. local condition = xpath.selectNodes(lom.parse(response.content),
  11. '//yweather:condition')[1]
  12. return string.format(
  13. 'Bellevue, WA has the condition "%s" and is %d degrees Farenheit.',
  14. condition.attr.

comments powered by Disqus