我快疯了,想弄明白这一点,我正试图建立一个多层次的简单菜单树
RootFolder
- First Sub Folder
-- First Sub Sub Folder
--- First Sub Sub Sub Folder
--- First Sub Sub Sub Sub Folder
- Second Sub Folder
- Second Sub Sub Folder
我的XML非常简单( 不是正确的值)
<OrgFolderDetails>
<FolderName>Main Folder</FolderName>
<TheChildren>
<OrgFolderDetails>
<FolderName>First Sub Folder</FolderName>
<TheChildren>
<OrgFolderDetails>
<FolderName>First Sub Sub Folder</FolderName>
<TheChildren>
<OrgFolderDetails>
<FolderName>First Sub Siub Sub Folder</FolderName>
<TheChildren>
<OrgFolderDetails>
<FolderName>First Sub Sub Sub Sub Folder</FolderName>
<TheChildren/>
</OrgFolderDetails>
</TheChildren>
</OrgFolderDetails>
</TheChildren>
</OrgFolderDetails>
</TheChildren>
</OrgFolderDetails>
<OrgFolderDetails>
<FolderName>Second Sub Folder</FolderName>
<TheChildren>
<OrgFolderDetails>
<FolderName>Second Sub Sub Folder</FolderName>
<TheChildren/>
</OrgFolderDetails>
</TheChildren>
</OrgFolderDetails>
</TheChildren>
</OrgFolderDetails>
我用jQuery s. filter () 和. find each () 毫无成功, 它没有给我很好的划线来表示我处于哪个级别, 它只是吐出文件夹名称 。
我的法则 穿越
$(data).find("FolderName").each(function(){
var folderName = $(this).text();
$("#folderLevels").append(folderName+"<br/>");
});