- differences between jet and odbc
- sugarcrm not inserting email
- select random records from access
- button click event firing twice
- how to send an email using cdosys
- installing perl on win2003 64 bit
- asp.net page event order
- rewrite rule for subdomains only
- extra items in javascript array
- IE7 margin auto not working
- IE7 border style dotted glitch
- ByRef and ByVal in vbscript
- weather rss feed
- Classic asp crib sheet
- Firefox onsubmit image change
- limit records in access
- AccessDataSource is thick
- double margins in IE6
- extra image padding in html emails
- decimal places in linux flash player
- broken emails in outlook 2007
- double spaced IE list items
- cannot remove movieclip
articles:
weather rss feed
Recently i decided that i wanted a weather rss feed on my mobile phone (a sony ericsson). The BBC provide a good weather feed so i subscribed to it. It downloaded fine the first time and i was happy. But come day two, when i looked for my updated weather feed i was disappointed to see the previous day's feed still there.
I didn't think that the phone was wrong as i had another feed from the BBC and this worked fine. After a bit of digging and comparing the two feeds it became apparent that it was because the GUID was not being changed from day to day in the weather feed. As i was really quite keen to have a working weather feed on my phone i decided i would load the feed on a remote server, change the GUID to be unique then write out the xml. My phone could then download this revised feed, and hopefully i would get an up to date daily weather report.
Additionally there was no Time To Live specified, and the pubdate and last build date were set to (none). I don't know whether these are required for the phone to update the feed but i thought it best to change them as well.
Here is the code (its on an American server hence the session.LCID and the dateadd):
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
session.LCID = 2057
Dim xmlID As String
'Thu, 21 Feb 2008 05:29:54 GMT
Dim rightNow as DateTime = dateAdd("h",5,DateTime.Now)
Dim theDate As String
theDate = rightNow.ToString("ddd, d MMM yyyy HH:mm:ss") & " GMT"
xmlID = Request.QueryString("xmlID")
If xmlID = "" Then xmlID = "0008"
Dim myXMLDocument As XmlDocument = New XmlDocument
Try
myXMLDocument.Load("http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/" + xmlID + ".xml")
Catch ex As Exception
myXMLDocument.Load("http://localhost/weather.xml")
End Try
Dim myXMLnodelist As XmlNodeList = myXMLDocument.GetElementsByTagName("pubDate")
myXMLnodelist.Item(0).ParentNode.RemoveChild(myXMLnodelist.Item(0))
'add the ttl to the document
Dim elem As XmlElement = myXMLDocument.CreateElement("ttl")
elem.InnerText = "15"
'Add the node to the document.
myXMLnodelist.Item(0).ParentNode.ParentNode.InsertBefore(elem, myXMLnodelist.Item(0).ParentNode.ParentNode.FirstChild)
For Each x As XmlNode In myXMLnodelist
x.InnerText = theDate
Next
myXMLnodelist = myXMLDocument.GetElementsByTagName("lastBuildDate")
myXMLnodelist.Item(0).InnerText = theDate
myXMLnodelist = myXMLDocument.GetElementsByTagName("guid")
For Each x As XmlNode In myXMLnodelist
x.InnerText = x.InnerText & " " & theDate
Next
Response.ContentType = "text/xml"
Response.Write(myXMLDocument.OuterXml.ToString)
End Sub
</script>
Does it work? Yes, now i have a working weather rss feed on my phone.
I didn't think that the phone was wrong as i had another feed from the BBC and this worked fine. After a bit of digging and comparing the two feeds it became apparent that it was because the GUID was not being changed from day to day in the weather feed. As i was really quite keen to have a working weather feed on my phone i decided i would load the feed on a remote server, change the GUID to be unique then write out the xml. My phone could then download this revised feed, and hopefully i would get an up to date daily weather report.
Additionally there was no Time To Live specified, and the pubdate and last build date were set to (none). I don't know whether these are required for the phone to update the feed but i thought it best to change them as well.
Here is the code (its on an American server hence the session.LCID and the dateadd):
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
session.LCID = 2057
Dim xmlID As String
'Thu, 21 Feb 2008 05:29:54 GMT
Dim rightNow as DateTime = dateAdd("h",5,DateTime.Now)
Dim theDate As String
theDate = rightNow.ToString("ddd, d MMM yyyy HH:mm:ss") & " GMT"
xmlID = Request.QueryString("xmlID")
If xmlID = "" Then xmlID = "0008"
Dim myXMLDocument As XmlDocument = New XmlDocument
Try
myXMLDocument.Load("http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/" + xmlID + ".xml")
Catch ex As Exception
myXMLDocument.Load("http://localhost/weather.xml")
End Try
Dim myXMLnodelist As XmlNodeList = myXMLDocument.GetElementsByTagName("pubDate")
myXMLnodelist.Item(0).ParentNode.RemoveChild(myXMLnodelist.Item(0))
'add the ttl to the document
Dim elem As XmlElement = myXMLDocument.CreateElement("ttl")
elem.InnerText = "15"
'Add the node to the document.
myXMLnodelist.Item(0).ParentNode.ParentNode.InsertBefore(elem, myXMLnodelist.Item(0).ParentNode.ParentNode.FirstChild)
For Each x As XmlNode In myXMLnodelist
x.InnerText = theDate
Next
myXMLnodelist = myXMLDocument.GetElementsByTagName("lastBuildDate")
myXMLnodelist.Item(0).InnerText = theDate
myXMLnodelist = myXMLDocument.GetElementsByTagName("guid")
For Each x As XmlNode In myXMLnodelist
x.InnerText = x.InnerText & " " & theDate
Next
Response.ContentType = "text/xml"
Response.Write(myXMLDocument.OuterXml.ToString)
End Sub
</script>
Does it work? Yes, now i have a working weather rss feed on my phone.