Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8490691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:11:58+00:00 2026-06-10T22:11:58+00:00

I’m currently trying to render a tree of Flickr Collections and Sets as HTML

  • 0

I’m currently trying to render a tree of Flickr Collections and Sets as HTML from C#. I’m using the Flickr.NET library to a list of all my collections with their childcollections and sets.

What I need to do is to render this tree as a HTML tree using nested unordered lists and I’m thinking of a recursive solution since a Collection can hold one or more sets and also hold child collections which again can hold sets and collections.

What I have right now is a list of all the root collections, their childcollections and their sets. So i.e. my Flickr tree looks like this:

  • Collection (this collection is in my list as an object itself)

    • Collection

      • Set
        • Photo1
        • Photo2
      • Set
        • Photo1
        • Photo2
    • Collection

      • Set
        • Photo1
        • Photo2
      • Set
        • Photo1
        • Photo2
  • Collection (this collection is in my list as an object itself)

    • Collection

      • Set
        • Photo1
        • Photo2
      • Set
        • Photo1
        • Photo2
    • Collection

      • Set
        • Photo1
        • Photo2
      • Set
        • Photo1
        • Photo2

And basically it could looks a hundred more ways since editors will eventually create a number more Collections within collections and sets within sets.

So, for every collection and set, I need a new nested unordered list.

I know this is quite complex, but nonetheless, it would be great to have an algorithm to render the tree as HTML. I’ve just become a tad too rusty when it comes to recursive algorithms :-/

I guess my basecase here is if the current collection doesn’t have any childcollections and doesn’t have any, then I can stop the recursive method?

Any help/hint on this is greatly appreciated!

Thanks a lot in advance.

All the best,

Bo

SOLUTION

I broke down the algorithms in four steps:

private void LoadFlickrTreeRecursive()
    {
        foreach (var collection in allCollections)
        {
            flickrTreeMarkup.Append("<ul class='collection'>");
            flickrTreeMarkup.Append("<li>" + collection.Title + "</li>");
            if (collection.Sets.Count > 0)
                RenderFlickPhotoSet(collection.Sets);

            if (collection.Collections.Count > 0)                
                RenderFlickrCollectionRecursive(collection.Collections);                    

            flickrTreeMarkup.Append("</ul>");
        }
    }

    private void RenderFlickPhotoSet(System.Collections.ObjectModel.Collection<CollectionSet> sets)
    {
        foreach (var set in sets)
        {
            flickrTreeMarkup.Append("<ul class='set'>");
            flickrTreeMarkup.Append("<li>" + set.Title + "</li>");
            var photos = flickr.PhotosetsGetPhotos(set.SetId);
            if (photos.Count > 0)
            {
                flickrTreeMarkup.Append("<ul class='photos'>");
                foreach (var photo in photos)
                {
                    flickrTreeMarkup.Append("<li>" + photo.Title + "</li>");
                }
                flickrTreeMarkup.Append("</ul>");
            }
            flickrTreeMarkup.Append("</ul>");                 
        }
    }

    private void RenderFlickrCollectionRecursive(System.Collections.ObjectModel.Collection<Collection> collections)
    {
        foreach (var collection in collections)
        {
            flickrTreeMarkup.Append("<ul class='collection'>");
            flickrTreeMarkup.Append("<li>" + collection.Title + "</li>");
            RenderFlickPhotoSet(collection.Sets);
            if (collection.Collections.Count > 0)
            {                    
                RenderFlickrCollectionRecursive(collection.Collections);                    
            }
            flickrTreeMarkup.Append("</ul>");                
        }            
    }

Works like a charm 🙂

However, if anyone know of a better way than this, please let me know. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:12:00+00:00Added an answer on June 10, 2026 at 10:12 pm

    This algorithm should work with a TreeView control:

    function rec(Collection c, TreeNode n)
    {
       TreeNode me = new TreeNode();
       n.ChildNodes.Add(me);
       for each collection v in c:
           rec(v, me)
       for each set s in c:
           AddSet(s, me)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a text area in my form which accepts all possible characters from
I am currently running into a problem where an element is coming back from
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.