Source: site.view [edit]
Function name: bookmarksToXML
Arguments: tag,user
Description: Converts all bookmarks for a user to an XML format, as defined by del.ico.us (http://del.icio.us/help/api/posts)
Page type: webl
Render function:  
Module: global

Page source:

// Get all bookmarks
var bookMarks = ToSet(Wub_GetFunctionsByTag("flag.bookmark"));

// Filter by tag
if tag != "" then
   bookMarks = bookMarks * ToSet(Wub_GetFunctionsByTag("tag." + tag));
end;

// Filter by user
if user != "" then
   bookMarks = bookMarks * ToSet(Wub_GetFunctionsByTag("createdby." + user));
end;

var posts = `<posts tag="` + tag + `" user="` + user + `">` + "\n";

// get function information for each bookmark
every bookmark in bookMarks do
   var info = Wub_GetFunctionInfo(bookmark);
   var label = Select(bookmark, Str_IndexOf(".", bookmark)+1, Size(bookmark));
   var tags = Wub_ReplaceAll(info.tags, ",", " ");
   var description = Wub_ReplaceAll(info.description, `"`, "'");

   posts = posts +
      `  <post shortcut="`+label+`" href="`+info.exec+`" description="` + 
         description + `" tag="` + tags + `" time="` + info.modified + 
         `" />` + "\n";
end;

// Return XML
posts = posts + "</posts>\n";
posts;