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 6651585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:01:48+00:00 2026-05-26T01:01:48+00:00

I have no previous experience with FubuMVC HtmlTags library, and I simply got stuck

  • 0

I have no previous experience with FubuMVC HtmlTags library, and I simply got stuck when trying to accomplish a simple nested structure like this:

<ul>
 <li>text</li>
 <li>text
   <ul>
     <li>subtext</li>
     <li>subtext</li>
   </ul>
 </li>
 <li>text</li>
</ul>

Here’s how I have it when building the string:

public static HtmlString ChildNodesRecursive(DocumentNode documentNode)        
{
    var tag="";
    if (documentNode.Children.Count > 0)
    {
        tag = "<ul>";
        foreach (var c in documentNode.Children)
        {
            tag += "<li>" + c.Name;
            tag += ChildNodesRecursive(c);
            tag += "</li>";
        }
        tag += "</ul>";
    }
    return new HtmlString(tag);
}

Works fine, but I like to use HtmlTags library (outside of FubuMvc, with the HtmlTags separate Nuget).

Edit : I got inspiration from both answers and came up with what I needed. So here’s the code I ended up using.

    public static HtmlTags.HtmlTag ChildNodesRecursiveHtmlTag(DocumentNode documentNode)
    {
        var ul = new HtmlTags.HtmlTag("ul");
        foreach (var c in documentNode.Children)
        {
            var li = new HtmlTags.HtmlTag("li");
            li.Add("a").Attr("href",c.ContextFullPath).Text(c.Name);
            if (c.Children.Count > 0)
            {
                li.Children.Add(ChildNodesRecursiveHtmlTag(c));
            }
            ul.Children.Add(li);
        }
        return ul;
    }
  • 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-05-26T01:01:48+00:00Added an answer on May 26, 2026 at 1:01 am

    I can give you an example which may make things clearer to you:

    var ul = new HtmlTag("span").AddClass("form_input");
    ul.Modify(t =>
    {
               foreach (var value in choice)
               {
                   t.Add("input")
                       .Attr("type", "radio")
                       .Attr("name", request.Accessor.Name)
                       .Attr("value", value)
                     .Add("span")
                       .AddClass("fixed-width")
                       .Text(value);
               }
    });
    

    Gives you something like

    <span class="form-input">
      <input type="radio" name="bla" value="foo" />
      <span class="fixed-width">foo</span>
      ...etc...
    </span>
    

    You can carry on nesting tags with modify and filling in the lambda. I think you will find that what you want to do is possible with the bits of syntax shown.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would like to start by saying I have no previous experience with SSH commands.
I am writing a simple database with web access. I have previous experience with
I am new to VBA but have previous experience with PHP programming logic and
I'm new to grails, but have previous experience using .net with c# and linq
Migrating from PHP to EJB , I have previous experience of PHP , C++
I have previous JSP experience but with using Tomcat and Resin and I would
I don't have any previous experience creating ActiveX-Controls. Information about the topic thats not
I've no previous experience with tools like Liquibase and similar. Up to now the
I have previous experience with MATLAB, but the problem that I face is some
Ok I am relatively new to Java Programming, but have previous experience in C++.

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.