Ok, I can read the RSS feed with classic ASP and display the entire feed, but I just want to display the actual temperature. Here is my code:
and here is what the feed looks like
What I can't figure out is how to just grab item/pubdate and item/yweather:condition/temp. If I try to change
to specify the element, I can't get down to the temp. Just like CSS, when I thought I had a good grasp, I want astray... Any help out there?
Willie
Code:
call getWeather(1)
Sub getWeather(howManyResults)
myRSSfile = "[URL unfurl="true"]http://weather.yahooapis.com/forecastrss?p=98119"[/URL]
Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.4.0")
xmlHttp.Open "Get", myRSSfile, false
xmlHttp.Send()
myXML = xmlHttp.ResponseText
Set xmlResponse = Server.CreateObject("MSXML2.DomDocument.4.0")
xmlResponse.async = false
xmlResponse.LoadXml(myXML)
Set xmlHttp = Nothing
Set objLst = xmlResponse.getElementsByTagName("item")
Set xmlResponse = Nothing
intNoOfHeadlines = objLst.length -1
For i = 0 To (intNoOfHeadlines)
Set objHdl = objLst.item(i)
for each child in objHdl.childNodes
Select case lcase(child.nodeName)
case "title"
title = child.text
case "link"
link = child.text
case "description"
description = child.text
End Select
next
kk = kk+1
if kk < howManyresults+1 then
Response.Write "<br /><a href=""" & link & """>" & title & "</a> <br
/>" & description
end if
Next
End sub
and here is what the feed looks like
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<rss version="2.0" xmlns:yweather="[URL unfurl="true"]http://weather.yahooapis.com/ns/rss/1.0"[/URL]
xmlns:geo="[URL unfurl="true"]http://www.w3.org/2003/01/geo/wgs84_pos#">[/URL]
<channel>
<title>Yahoo! Weather - Sunnyvale, CA</title>
<link>[URL unfurl="true"]http://us.rd.yahoo.com/dailynews/rss/weather/Sunnyvale__CA/[/URL]
*[URL unfurl="true"]http://weather.yahoo.com/forecast/94089_f.html</link>[/URL]
<description>Yahoo! Weather for Sunnyvale, CA</description>
<language>en-us</language>
<lastBuildDate>Tue, 29 Nov 2005 3:56 pm PST</lastBuildDate>
<ttl>60</ttl>
<yweather:location city="Sunnyvale" region="CA" country="US"></yweather:location>
<yweather:units temperature="F" distance="mi" pressure="in" speed="mph"></yweather:units>
<yweather:wind chill="57" direction="350" speed="7"></yweather:wind>
<yweather:atmosphere humidity="93" visibility="1609" pressure="30.12" rising="0"></yweather:atmosphere>
<yweather:astronomy sunrise="7:02 am" sunset="4:51 pm"></yweather:astronomy>
<image>
<title>Yahoo! Weather</title>
<width>142</width>
<height>18</height>
<link>[URL unfurl="true"]http://weather.yahoo.com/</link>[/URL]
<url>[URL unfurl="true"]http://l.yimg.com/a/i/us/nws/th/main_142b.gif</url>[/URL]
</image>
<item>
<title>Conditions for Sunnyvale, CA at 3:56 pm PST</title>
<geo:lat>37.39</geo:lat>
<geo:long>-122.03</geo:long>
<link>[URL unfurl="true"]http://us.rd.yahoo.com/dailynews/rss/weather/[/URL]
Sunnyvale__CA/*
[URL unfurl="true"]http://weather.yahoo.com/[/URL] forecast/94089_f.html
</link>
<pubDate>Tue, 29 Nov 2005 3:56 pm PST</pubDate>
<yweather:condition text="Mostly Cloudy" code="26" temp="57" date="Tue, 29 Nov 2005 3:56
pm PST"></yweather:condition>
<description><![CDATA[
<img src="[URL unfurl="true"]http://l.yimg.com/a/i/us/we/52/26.gif"[/URL] /><br />
<b>Current Conditions:</b><br />
Mostly Cloudy, 57 F<p />
<b>Forecast:</b><BR />
Tue - Mostly Cloudy. High: 62 Low: 45<br />
Wed - Mostly Cloudy. High: 60 Low: 52<br />
Thu - Rain. High: 61 Low: 46<br />
<br />
<a href="[URL unfurl="true"]http://us.rd.yahoo.com/dailynews/rss/weather/Sunnyvale__CA/*http://weather.yahoo.com/forecast/94089_f.html">Full[/URL] Forecast at Yahoo! Weather</a><BR/>
(provided by The Weather Channel)<br/>]]>
</description>
<yweather:forecast day="Tue" date="29 Nov 2005" low="45" high="62" text="Mostly Cloudy"
code="27"></yweather:forecast>
<yweather:forecast day="Wed" date="30 Nov 2005" low="52" high="60" text="Mostly Cloudy"
code="28"></yweather:forecast>
<guid isPermaLink="false">94089_2005_11_29_15_56_PST</guid>
</item>
</channel>
</rss>
What I can't figure out is how to just grab item/pubdate and item/yweather:condition/temp. If I try to change
Code:
Set objLst = xmlResponse.getElementsByTagName("item")
Willie