These feeds are delicious!

delicious logo

Delicious has a series of RSS feeds we can consume in our VBA programs. Here's some sample code for doing so.

I didn't try out all of the available feeds, just the ones that didn't require a MD5 hash or a private key. Don't forget to grab the helper functions, they'll be used by each of the below functions. Also, note that Delicious is a bit strict when it comes to automated usage. Try not to run these functions more than once or twice every few seconds, or risk getting your IP banned.

All this talk about delicious, feeds and consuming is making me hungry; I'm going to go get something to eat.

Hotlist bookmarks

These are the bookmarks from the Delicious Hotlist. Don't ask me what that means.

There is some light hardcoding here, due to the XML response. For example, the first four nodes of the XML response are skipped.

Function DeliciousHotListBookmarks(Optional numberOfResults As Long = 15) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim channel As Object ' MSXML2.IXMLDOMNodeList
Dim items As Object ' MSXML2.IXMLDOMNodeList
Dim item As Object ' MSXML2.IXMLDOMNode
Dim i As Long, j As Long

  tempFile = environ("temp") & "\delicioushotlistbookmarks.xml"

  ' requery website if file doesn't already exist
  If Len(Dir(tempFile)) = 0 Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "http://feeds.delicious.com/v2/rss?count=" & _
    numberOfResults, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateXMLFile(tempFile, result)

  End If

  ' open XML file
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get root node
  Set xmlDocRoot = GetRootNode(xmlDoc)
  ' get second level nodes
  Set channel = GetChildNodes(xmlDocRoot)
  ' get third level nodes
  Set items = GetChildNodes(channel.item(0))

  ' resize array
  ReDim tempString(1 To (items.Length - 4), 1 To items.item(4).childNodes.Length)

  ' loop through all items starting at node 4
  For i = 4 To items.Length - 1
    Set item = items.item(i)

    For j = 1 To items.item(i).childNodes.Length
      tempString(i - 3, j) = item.childNodes(j - 1).nodeTypedValue
    Next j
  Next i

  DeliciousHotListBookmarks = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim i As Long, j As Long

  ' get three links
  tempString = DeliciousHotListBookmarks(3)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Bookmarks by user

Pass in the userid and the number of bookmarks (maximum 100) and this function will return the bookmarks for that user.

Function DeliciousUserBookmarks(userid As String, _
    Optional numberOfResults As Long = 15) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim channel As Object ' MSXML2.IXMLDOMNodeList
Dim items As Object ' MSXML2.IXMLDOMNodeList
Dim item As Object ' MSXML2.IXMLDOMNode
Dim i As Long, j As Long
Dim maxNodes As Long

  tempFile = environ("temp") & "\delicious" & userid & "bookmarks.xml"

  ' requery website if file doesn't already exist
  If Len(Dir(tempFile)) = 0 Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "http://feeds.delicious.com/v2/rss/" & userid & _
    "?count=" & numberOfResults, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateXMLFile(tempFile, result)

  End If

  ' open XML file
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get root node
  Set xmlDocRoot = GetRootNode(xmlDoc)
  ' get second level nodes
  Set channel = GetChildNodes(xmlDocRoot)
  ' get third level nodes
  Set items = GetChildNodes(channel.item(0))

  ' get max number of nodes,
  ' since each URL can have a different amt of tags
  maxNodes = items.item(4).childNodes.Length

  For i = 4 To items.Length - 1
    maxNodes = Application.max(maxNodes, items.item(i).childNodes.Length)
  Next i

  ' resize array
  ReDim tempString(1 To (items.Length - 4), 1 To maxNodes)

  ' loop through all items
  For i = 4 To items.Length - 1
    Set item = items.item(i)

    For j = 1 To items.item(i).childNodes.Length
      tempString(i - 3, j) = item.childNodes(j - 1).nodeTypedValue
    Next j
  Next i

  DeliciousUserBookmarks = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim i As Long, j As Long

  ' my userid
  userid = "jp2112"

  tempString = DeliciousUserBookmarks(userid, 3)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Popular Delicious Bookmarks By Tag

Pass in a single tag and this function returns bookmarks that were tagged with that keyword.

Function DeliciousPopularBookmarksByTag(tag As String) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim channel As Object ' MSXML2.IXMLDOMNodeList
Dim items As Object ' MSXML2.IXMLDOMNodeList
Dim item As Object ' MSXML2.IXMLDOMNode
Dim i As Long, j As Long
Dim maxNodes As Long

  tempFile = environ("temp") & "\delicious" & tag & "bookmarks.xml"

  ' requery website if file doesn't already exist
  If Len(Dir(tempFile)) = 0 Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "http://feeds.delicious.com/v2/rss/popular/" & tag, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateXMLFile(tempFile, result)

  End If

  ' open XML file
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get root node
  Set xmlDocRoot = GetRootNode(xmlDoc)
  ' get second level nodes
  Set channel = GetChildNodes(xmlDocRoot)
  ' get third level nodes
  Set items = GetChildNodes(channel.item(0))

  ' get max number of nodes,
  ' since each URL can have a different # of tags
  maxNodes = items.item(4).childNodes.Length

  For i = 4 To items.Length - 1
    maxNodes = Application.max(maxNodes, items.item(i).childNodes.Length)
  Next i

  ' resize array
  ReDim tempString(1 To (items.Length - 4), 1 To maxNodes)

  ' loop through all items
  For i = 4 To items.Length - 1
    Set item = items.item(i)

    For j = 1 To items.item(i).childNodes.Length
      tempString(i - 3, j) = item.childNodes(j - 1).nodeTypedValue
    Next j
  Next i

  DeliciousPopularBookmarksByTag = tempString

End Function

Sample usage

This will return popular bookmarks tagged with "VBA".

Sub TestDelicious()

Dim tempString() As String
Dim tag As String
Dim i As Long, j As Long

  tag = "VBA"

  tempString = DeliciousPopularBookmarksByTag(tag)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Recent Bookmarks

This function will return the last X bookmarks added by Delicious users.

Function DeliciousRecentBookmarks(Optional numberOfResults As Long = 15) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim channel As Object ' MSXML2.IXMLDOMNodeList
Dim items As Object ' MSXML2.IXMLDOMNodeList
Dim item As Object ' MSXML2.IXMLDOMNode
Dim i As Long, j As Long
Dim maxNodes As Long

  tempFile = environ("temp") & "\deliciousrecentbookmarks.xml"

  ' requery website if file doesn't already exist
  If Len(Dir(tempFile)) = 0 Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "http://feeds.delicious.com/v2/rss/recent?count" & _
    numberOfResults, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateXMLFile(tempFile, result)

  End If

  ' open XML file
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get root node
  Set xmlDocRoot = GetRootNode(xmlDoc)
  ' get second level nodes
  Set channel = GetChildNodes(xmlDocRoot)
  ' get third level nodes
  Set items = GetChildNodes(channel.item(0))

  ' get max number of nodes,
  ' since each URL can have a different # of tags
  maxNodes = items.item(4).childNodes.Length

  For i = 4 To items.Length - 1
    maxNodes = Application.max(maxNodes, items.item(i).childNodes.Length)
  Next i

  ' resize array
  ReDim tempString(1 To (items.Length - 4), 1 To maxNodes)

  ' loop through all items
  For i = 4 To items.Length - 1
    Set item = items.item(i)

    For j = 1 To items.item(i).childNodes.Length
      tempString(i - 3, j) = item.childNodes(j - 1).nodeTypedValue
    Next j
  Next i

  DeliciousRecentBookmarks = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim i As Long, j As Long

  tempString = DeliciousRecentBookmarks(3)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Recent Bookmarks Filtered by Tag

This function will return recent bookmarks, but they will be filtered by the tags list you provide. The tags should be plus(+)-delimited, i.e. tag1+tag2+tag3+tag4

Function DeliciousRecentBookmarksByTag(tagList As String, _
    Optional numberOfResults As Long = 15) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim channel As Object ' MSXML2.IXMLDOMNodeList
Dim items As Object ' MSXML2.IXMLDOMNodeList
Dim item As Object ' MSXML2.IXMLDOMNode
Dim i As Long, j As Long
Dim maxNodes As Long

  tempFile = environ("temp") & "\deliciousrecentbookmarks" & tagList & ".xml"

  ' requery website if file doesn't already exist
  If Len(Dir(tempFile)) = 0 Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "http://feeds.delicious.com/v2/rss/tag/" & tagList & _
    "?count" & numberOfResults, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateXMLFile(tempFile, result)

  End If

  ' open XML file
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get root node
  Set xmlDocRoot = GetRootNode(xmlDoc)
  ' get second level nodes
  Set channel = GetChildNodes(xmlDocRoot)
  ' get third level nodes
  Set items = GetChildNodes(channel.item(0))

  ' get max number of nodes,
  ' since each URL can have a different # of tags
  maxNodes = items.item(4).childNodes.Length

  For i = 4 To items.Length - 1
    maxNodes = Application.max(maxNodes, items.item(i).childNodes.Length)
  Next i

  ' resize array
  ReDim tempString(1 To (items.Length - 4), 1 To maxNodes)

  ' loop through all items
  For i = 4 To items.Length - 1
    Set item = items.item(i)

    For j = 1 To items.item(i).childNodes.Length
      tempString(i - 3, j) = item.childNodes(j - 1).nodeTypedValue
    Next j
  Next i

  DeliciousRecentBookmarksByTag = tempString

End Function

Sample usage

This will return the three most recent bookmarks tagged with "VBA".

Sub TestDelicious()

Dim tempString() As String
Dim tag As String
Dim i As Long, j As Long

  tag = "VBA"

  tempString = DeliciousRecentBookmarksByTag(tag, 3)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Popular Bookmarks

This function will return the most popular bookmarks on the site, up to a maximum of 100.

Function DeliciousPopularBookmarks(Optional numberOfResults As Long = 15) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim channel As Object ' MSXML2.IXMLDOMNodeList
Dim items As Object ' MSXML2.IXMLDOMNodeList
Dim item As Object ' MSXML2.IXMLDOMNode
Dim i As Long, j As Long
Dim maxNodes As Long

  tempFile = environ("temp") & "\deliciouspopularbookmarks.xml"

  ' requery website if file doesn't already exist
  If Len(Dir(tempFile)) = 0 Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "http://feeds.delicious.com/v2/rss/popular?count=" & _
    numberOfResults, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateXMLFile(tempFile, result)

  End If

  ' open XML file
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get root node
  Set xmlDocRoot = GetRootNode(xmlDoc)
  ' get second level nodes
  Set channel = GetChildNodes(xmlDocRoot)
  ' get third level nodes
  Set items = GetChildNodes(channel.item(0))

  ' get max number of nodes,
  ' since each URL can have a different # of tags
  maxNodes = items.item(4).childNodes.Length

  For i = 4 To items.Length - 1
    maxNodes = Application.max(maxNodes, items.item(i).childNodes.Length)
  Next i

  ' resize array
  ReDim tempString(1 To (items.Length - 4), 1 To maxNodes)

  ' loop through all items
  For i = 4 To items.Length - 1
    Set item = items.item(i)

    For j = 1 To items.item(i).childNodes.Length
      tempString(i - 3, j) = item.childNodes(j - 1).nodeTypedValue
    Next j
  Next i

  DeliciousPopularBookmarks = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim i As Long, j As Long

  tempString = DeliciousPopularBookmarks(3)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Bookmarks for a given user filtered by tag

This function returns the bookmarks for a given user filtered by a list of tags. If more than one tag is passed, the string must be plus(+)-delimited, i.e. tag1+tag2+tag3+tag4.

Function DeliciousBookmarksForUserByTag(userid As String, tagList As String, _
    Optional numberOfResults As Long = 15) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim channel As Object ' MSXML2.IXMLDOMNodeList
Dim items As Object ' MSXML2.IXMLDOMNodeList
Dim item As Object ' MSXML2.IXMLDOMNode
Dim i As Long, j As Long
Dim maxNodes As Long

  tempFile = environ("temp") & "\deliciousbookmarksFor" & userid & tagList & ".xml"

  ' requery website if file doesn't already exist
  If Len(Dir(tempFile)) = 0 Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "http://feeds.delicious.com/v2/rss/" & userid & "/" & _
    tagList & "?count=" & numberOfResults, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateXMLFile(tempFile, result)

  End If

  ' open XML file
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get root node
  Set xmlDocRoot = GetRootNode(xmlDoc)
  ' get second level nodes
  Set channel = GetChildNodes(xmlDocRoot)
  ' get third level nodes
  Set items = GetChildNodes(channel.item(0))

  ' get max number of nodes,
  ' since each URL can have a different # of tags
  maxNodes = items.item(4).childNodes.Length

  For i = 4 To items.Length - 1
    maxNodes = Application.max(maxNodes, items.item(i).childNodes.Length)
  Next i

  ' resize array
  ReDim tempString(1 To (items.Length - 4), 1 To maxNodes)

  ' loop through all items
  For i = 4 To items.Length - 1
    Set item = items.item(i)

    For j = 1 To items.item(i).childNodes.Length
      tempString(i - 3, j) = item.childNodes(j - 1).nodeTypedValue
    Next j
  Next i

  DeliciousBookmarksForUserByTag = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim tag As String
Dim i As Long, j As Long

  userid = "jp2112"
  tag = "VBA"

  tempString = DeliciousBookmarksForUserByTag(userid, tag, 3)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

User Information

Return various information about a given user, such as how many other members are in a user's network.

Function DeliciousUserInfo(userid As String) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim channel As Object ' MSXML2.IXMLDOMNodeList
Dim items As Object ' MSXML2.IXMLDOMNodeList
Dim item As Object ' MSXML2.IXMLDOMNode
Dim i As Long, j As Long

Const maxNodes As Long = 3

  tempFile = environ("temp") & "\delicioususerinfo" & userid & ".xml"

  ' requery website if file doesn't already exist
  If Len(Dir(tempFile)) = 0 Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "http://feeds.delicious.com/v2/rss/userinfo/" & _
    userid, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateXMLFile(tempFile, result)

  End If

  ' open XML file
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get root node
  Set xmlDocRoot = GetRootNode(xmlDoc)
  ' get second level nodes
  Set channel = GetChildNodes(xmlDocRoot)
  ' get third level nodes
  Set items = GetChildNodes(channel.item(0))

  ' resize array
  ReDim tempString(1 To maxNodes, 1 To maxNodes)

  ' loop through all items
  For i = 4 To items.Length - 1
    Set item = items.item(i)

    For j = 1 To items.item(i).childNodes.Length
      tempString(i - 3, j) = item.childNodes(j - 1).nodeTypedValue
    Next j
  Next i

  DeliciousUserInfo = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim i As Long, j As Long

  userid = "jp2112"

  tempString = DeliciousUserInfo(userid)
  For i = 1 To UBound(tempString)
    For j = 1 To UBound(tempString, 2)
      Debug.Print tempString(i, j)
    Next j
  Next i
End Sub

Get Related Tags

This function accepts a list of tags and returns tags used on the same bookmarks. Like the other functions above, if more than one tag is passed, the string must be plus(+)-delimited, i.e. tag1+tag2+tag3+tag4.

Function DeliciousRelatedTags(userid As String, tagList As String, _
    Optional numberOfResults As Long = 15) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim channel As Object ' MSXML2.IXMLDOMNodeList
Dim items As Object ' MSXML2.IXMLDOMNodeList
Dim item As Object ' MSXML2.IXMLDOMNode
Dim i As Long

  tempFile = environ("temp") & "\deliciousrelatedtags" & userid & tagList & ".xml"

  ' requery website if file doesn't already exist
  If Len(Dir(tempFile)) = 0 Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "http://feeds.delicious.com/v2/rss/tags/" & userid & _
    "/" & tagList & "?count=" & numberOfResults, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateXMLFile(tempFile, result)

  End If

  ' open XML file
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get root node
  Set xmlDocRoot = GetRootNode(xmlDoc)
  ' get second level nodes
  Set channel = GetChildNodes(xmlDocRoot)
  ' get third level nodes
  Set items = GetChildNodes(channel.item(0))

  ' resize array, drop the first four nodes
  ReDim tempString(1 To items.Length - 4)

  ' loop through all items (except the first four nodes)
  For i = 4 To items.Length - 1
    Set item = items.item(i)

    tempString(i - 3) = item.childNodes(0).nodeTypedValue
  Next i

  DeliciousRelatedTags = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim tag As String
Dim i As Long

  userid = "jp2112"
  tag = "Excel+VBA"

  tempString = DeliciousRelatedTags(userid, tag, 3)
  For i = 1 To UBound(tempString)
    Debug.Print tempString(i)
  Next i
End Sub

Get all public tags for a user

Function DeliciousAllPublicTags(userid As String, _
    Optional numberOfResults As Long = 15) As String()

Dim xml As Object ' MSXML2.XMLHTTP
Dim result As String
Dim tempFile As String
Dim tempString() As String
Dim xmlDoc As Object ' MSXML2.DOMDocument
Dim xmlDocRoot As Object ' MSXML2.IXMLDOMNode
Dim channel As Object ' MSXML2.IXMLDOMNodeList
Dim items As Object ' MSXML2.IXMLDOMNodeList
Dim item As Object ' MSXML2.IXMLDOMNode
Dim i As Long

  tempFile = environ("temp") & "\deliciousallpublictags" & userid & ".xml"

  ' requery website if file doesn't already exist
  If Len(Dir(tempFile)) = 0 Then

    Set xml = CreateObject("MSXML2.XMLHTTP.6.0")

    xml.Open "GET", "http://feeds.delicious.com/v2/rss/tags/" & userid & _
    "?count=" & numberOfResults, False
    xml.Send

    result = xml.responseText

    ' create XML file from result
    Call CreateXMLFile(tempFile, result)

  End If

  ' open XML file
  Set xmlDoc = CreateObject("MSXML2.DOMDocument")

  With xmlDoc
    .async = False
    .validateOnParse = False
    .Load tempFile
  End With

  ' check that the XML doc loaded
  If LoadError(xmlDoc) Then
    Exit Function
  End If

  ' get root node
  Set xmlDocRoot = GetRootNode(xmlDoc)
  ' get second level nodes
  Set channel = GetChildNodes(xmlDocRoot)
  ' get third level nodes
  Set items = GetChildNodes(channel.item(0))

  ' resize array, drop the first four nodes
  ReDim tempString(1 To items.Length - 4)

  ' loop through all items (except the first four nodes)
  For i = 4 To items.Length - 1
    Set item = items.item(i)

    tempString(i - 3) = item.childNodes(0).nodeTypedValue
  Next i

  DeliciousAllPublicTags = tempString

End Function

Sample usage

Sub TestDelicious()

Dim tempString() As String
Dim userid As String
Dim i As Long

  userid = "jp2112"

  tempString = DeliciousAllPublicTags(userid, 3)
  For i = 1 To UBound(tempString)
    Debug.Print tempString(i)
  Next i

End Sub

Note: You might be using the del.icio.us API or the workbook found here: Working with the del.icio.us API in VBA. According to the Yahoo Developer Blog, all Yahoo APIs (including delicious which is owned by Yahoo) will be converted to use YQL, their own version of SQL. While this will mean more flexibility, it will also mean that any existing API code may stop working at any time, and will most likely be unsupported. So I fully expect the delicious workbook to stop working. I will soon be publishing the last of the API code I was working on for del.icio.us, and that will be it until I get up to speed with YQL.

Related Articles:

About JP

I'm just an average guy who writes VBA code for a living. This is my personal blog. Excel and Outlook are my thing, with a sprinkle of Access and Word here and there. Follow this space to learn more about VBA. Keep Reading »

Share This Article:

Share and bookmark this articledelicious buttonfacebook buttonlinkedin buttonstumbleupon buttontwitter button
Comments on this article are closed. Why?

Site last updated: February 9, 2012