Option Public Option Explicit Use "UrlFetcherLS" Use "XmlNodeReader" Sub Initialize Dim atomUrl As String Dim fetcher As New UrlFetcher Dim response As String '** use a UrlFetcher to retrieve the Flickr ATOM feed. See '** http://www.nsftools.com/blog/blog-05-2007.htm#05-22-07 atomUrl = "http://api.flickr.com/services/feeds/photos_public.gne" response = fetcher.getUrlAsString( atomUrl ) If (Len(fetcher.getLastError()) > 0) Then Messagebox "Error getting ATOM feed: " + fetcher.getLastError() Exit Sub End If '** read the feed into an XmlNodeReader Dim reader As New XmlNodeReader Call reader.ReadText( response ) If reader.isEmpty Then Messagebox "Error parsing ATOM feed: " & reader.getLastError() Exit Sub End If '** print the feed title Print "ATOM Title = " & reader.get( "feed.title" ) '** there may be more than one <link> nodes; we want the rel="alternate" link Dim links As Variant links = ArraysToList( reader.getAll("feed.link.@rel"), reader.getAll("feed.link.@href") ) Print "Site Link = " & links("alternate") '** iterate through all the <entry> nodes and print their title and link Dim arr As Variant Dim i As Integer arr = reader.getNodeReaders("feed.entry") For i = 0 To Ubound(arr) Print "Feed Item #" & i+1 & " Title = " & arr(i).get( "title" ) links = ArraysToList( arr(i).getAll("link.@rel"), arr(i).getAll("link.@href") ) Print "Feed Item #" & i+1 & " Link = " & links("alternate") Next End Sub Function ArraysToList (arr1 As Variant, arr2 As Variant) As Variant Dim count As Integer count = Ubound(arr1) If (Ubound(arr2) < count) Then count = Ubound(arr2) Dim returnVal List As Variant Dim i As Integer For i = 0 To count returnVal(arr1(i)) = arr2(i) Next ArraysToList = returnVal End Function
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.