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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:12:28+00:00 2026-05-27T09:12:28+00:00

i have the following data root root/blue root/blue/temp root/main root/main/dev root/main/back root/etc/init root/etc/init/dev root/etc/init/test

  • 0

i have the following data

root
root/blue
root/blue/temp
root/main
root/main/dev
root/main/back
root/etc/init
root/etc/init/dev
root/etc/init/test
root/etc/init/back
root/etc/init/server
root/etc/init/system
root/etc/init/setup
root/system
root/system/temp1
root/system/temp2
root/system/temp3
root/system/temp4
root/system/temp5
root/system/temp5/dev1
root/rel
root/intel/archival
root/intel/archival/newsreel
root/intel/archival/recording

i would like to be able to use the class to either databind to a tree control (ASP.Net) or generate a UL/Li for jquery consumption.

I need to convert it to a List class that will return the proper hierarchy. I have tried many different approach so far, and I’m not able to find a solution. I’m stuck. I tried asking in an earlier post but the solution did not work, after many attempts to modify some it just plain does not work. I hope one of you can help me out.

Also this is not a simple split functions, I know how to split a string.

Thank you in advance

  • 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-27T09:12:29+00:00Added an answer on May 27, 2026 at 9:12 am

    Here is a solution that generates a nested dictionary of NodeEntry items:

    public class NodeEntry
    {
        public NodeEntry()
        {
            this.Children = new NodeEntryCollection();
        }
    
        public string Key { get; set; }
        public NodeEntryCollection Children { get; set; }
    
    }
    
    public class NodeEntryCollection : Dictionary<string, NodeEntry>
    {
        public void AddEntry(string sEntry, int wBegIndex)
        {
            if (wBegIndex < sEntry.Length)
            {
                string sKey;
                int wEndIndex;
    
                wEndIndex = sEntry.IndexOf("/", wBegIndex);
                if (wEndIndex == -1)
                {
                    wEndIndex = sEntry.Length;
                }
                sKey = sEntry.Substring(wBegIndex, wEndIndex - wBegIndex);
                if (!string.IsNullOrEmpty(sKey)) {
                    NodeEntry oItem;
    
                    if (this.ContainsKey(sKey)) {
                        oItem = this[sKey];
                    } else {
                        oItem = new NodeEntry();
                        oItem.Key = sKey;
                        this.Add(sKey, oItem);
                    }
                    // Now add the rest to the new item's children
                    oItem.Children.AddEntry(sEntry, wEndIndex + 1);
                }
            }
        }
    }
    

    To use the above, create a new collection:

            NodeEntryCollection cItems = new NodeEntryCollection();
    

    then, for each line in your list:

            cItems.AddEntry(sLine, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following data in my database (comma separated strings): word, test, hello
I have the following code to get user data form facebook <div id=fb-root></div> <script>
I have a structure similar to the following: /root/ /root/data/ /root/data/script.php /root/data/some.json /root/data/feature/one.json /root/data/feature/two.json
I have following setup in cloud9 IDE. Project root folder Hello.html - contains simple
I have the following test case xaml. <Window.Resources> <XmlDataProvider x:Key=testDS1> <x:XData> <root xmlns=> <item>1</item>
In my /etc/bash.bashrc file, I have following: export SYNCTOOL=/root/Desktop/gb alias synctest='python $SYNCTOOL/App.py' In App.py:
I have following data to save in database using php my data is :
I have following data in my table. alt text http://img26.imageshack.us/img26/3746/productfield.png I want to extract
Hi I have following data in the table: ID-----startDate----endDate 5549 2008-05-01 4712-12-31 5567 2008-04-17
I have the following data structure (a list of lists) [ ['4', '21', '1',

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.