Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RSS feed protocol for last build date
Message
 
To
26/08/2004 11:31:22
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00935761
Message ID:
00936746
Views:
29
There are a couple of problems with the code below. First you can't RETURN from a TRY/CATCH - that will cause a runtime error (in fact it should give you a compile time error).

You probably want a generic routine to handle the retrieving of node values because you have to basically check for NULL on all of them. Something like this:
************************************************************************
* rss2Feed :: GetItem
****************************************
***  Function: Retrieves a node by XPath value
***    Assume:
***      Pass:
***    Return:
************************************************************************
PROTECTED FUNCTION GetItem(loDomNode,lcKey) as String

loNode = loDOMNode.selectSingleNode(lcKey)
IF ISNULL(loNode)
   RETURN ""
ENDIF
RETURN loNode.Text
or you can use wwXML.XPathValueToFoxValue which works similiarily but can also perform type conversion for you. For example, it will do the datetime conversion for you.

Regards,

+++ Rick ---



>>LastBuildDate is an optional schema item.
>
>Ok
>
>>What are you doing to parse this? Parsing Rss 2.0 is pretty straightforward - I have a class for that somewhere. In fact if you check your DevTeach CD I think the sample is on there (although I never actually showed it <g>).
>
>I was not at DevTeach this year. :)
>
>>If you manually parse the doc you have to make sure you check for null nodes returned and skip over those.
>
>Yes, I do something like that. So far, this is where I am:
>
>
>* expN1 Member ID
>* expC1 Blog URL
>FUNCTION BlogUpdate
>PARAMETERS tnNumero,tcBlog
>LOCAL lnOldSel,loHTTP,loXML,lcDate
>lnOldSel=SELECT()
>tcBlog=ALLTRIM(tcBlog)
>
>loHTTP=CREATEOBJECT('Msxml2.ServerXMLHTTP')
>loHTTP.Open('GET',tcBlog,.F.)
>
>* Set a timeout in order to avoid long request to time out the server
>loHTTP.setTimeouts(20000,20000,20000,20000)
>
>* We need to trap for possible errors
>TRY
>   loHTTP.Send()
>CATCH
>   RETURN
>ENDTRY
>
>* Just to make sure we have an object
>IF TYPE('loHTTP.ResponseXML')<>'O'
>   RETURN
>ENDIF
>
>loXML=loHTTP.ResponseXML
>
>* Check for the presence of the node
>loNodes=loXML.selectNodes('rss/channel/lastBuildDate')
>IF loNodes.Length=0
>   RETURN
>ENDIF
>
>lcDate=loXML.SelectSingleNode('rss/channel/lastBuildDate').Text
>
>* Update the blog update
>SELECT Member
>SEEK tnNumero ORDER TAG Numero
>REPLACE BlogUpdate WITH UTCToDateTime(lcDate)
>
>SELECT(lnOldSel)
>
>
>As you can see, I do not scroll all items for the pubDate node which is probably what you are making reference to. Just that piece of code would save me some time if you could show it to me.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform