解析URL字符串到树层次 [英] Parse Url Strings into Tree Hierarchy

查看:207
本文介绍了解析URL字符串到树层次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有具有在其网页列表的标题表。每个记录有一个页面的URL字段,我期待解析出成层次结构(树视图)。我不知道的最好的方式去了解它,我有一个问题,得到它的工作。

I have a header table that has a list of web pages in it. Each record has a page URL field which I am looking to parse out into a hierarchy (TreeView). I am not sure of the best way to go about it and I am having a problem getting it to work.

下面是URL的例子:

/file1.aspx
/file2.aspx
/aFolder/file.aspx
/aFolder/file2.aspx
/bfolder/file.aspx
/bFolder/cFolder/file.aspx

我希望把这种类型的列表到一个文件浏览器式的树状视图,你可以展开文件夹,然后选择在最后的文件。

I want to put this type of a list into a file explorer style treeview that you can expand the folders and then select the file at the end.

类似于

--Root
  |
  +-aFolder
  |   - aFolderFile1.aspx
  |   - aFolderFile2.aspx
  +-bFolder
      +-cFolder
      |    -cFolderFile1.aspx
      -bFolderFile1.aspx

真正的数据显然在每个更多的子文件夹和文件。

The real data obviously has more sub folders and files in each.

我在找的是一些code,无论是.NET或SQL来分析我的琴弦。我曾尝试使用一些SQL所使用 UNION ALL 但我可以'弄不明白为我工作。

What I am looking for is some code, be it .NET or SQL to parse my strings. I have tried to use some SQL that used WITH and UNION ALL but I just can't get it to work for me.

为了将其绑定到一个TreeView,数据源需要有才能的相关节点的父字段。因此,例如父为文件cFolderFile1.aspx是cFolder和cFolder具有bFolder的父,等等...

In order to bind it to a TreeView, the data source needs to have a parent field in order to relate the nodes. So, for example the parent for the file cFolderFile1.aspx is cFolder and the cFolder has a parent of bFolder, and so on....

我希望我已经包含了足够的信息。如果没有,请让我知道,我会编辑的帖子。

Hopefully I've included enough information. If not, please let me know and I will edit the post.

推荐答案

感谢您的建议每一个人。没有一个环节似乎正是我一直在寻找所以我最终把东西在一起。

Thanks for the suggestions everyone. None of the links seemed to be exactly what I was looking for so I ended up putting something together.

还有一堆code,但在一般情况下,我读的URL列表与一些额外的属性一个通用的列表,并使用了一些正则表达式语句解析出的路径。

There is a bunch of code, but in general, I read the list of URLs into a Generic List with some extra properties and used some regex statements to parse out the path.

由于URL列表中,没有任何形式的父ID /子ID,我用的查找功能,并得到了我所需要的部分。

Because the list of URLS did not have any sort of parent ID / child ID, I used the FIND function and got the pieces I needed.

这篇关于解析URL字符串到树层次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆