473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Recursively creating a DOM Tree

Hi,

I'm new to all this so any help would be appreciated.

I'm trying to build a DOM Tree by retrieving info from the database
and storing these objects as elements.

I have a structure a bit like windows explorer with folders within
folder within folders.... e.g.

<folder id="1" parent="0">
<title>Folder 1</title>
<folder id="2" parent="1">
<title>Sub Folder 1</title>
</folder>
</folder>

Now I've written a recursive function that calls until the last folder
is reached. It looks like this:

--------------------------------------------------------------------------------
<snip>

function traverseFolderNodes(folderId, parentFolder)
sql = "SELECT a.id, a.folderName, b.parentId FROM tblFolders a INNER
JOIN tblFolders_To_Folders b " & _
"ON b.childId = a.id WHERE b.parentId = " & folderId

set rsFolder = SQLString(sql)
if not rsFolder.EOF then

***PROBLEM ON LINE BELOW***

xmlGenerator.createElement "entity", folderElement
xmlGenerator.createTextElement "title", titleElement,
rsFolder("folderName")
xmlGenerator.createTextElement "image", imageElement,
"img/book.gif"
xmlGenerator.createTextElement "imageopen", imageOpenElement,
"img/bookopen.gif"
xmlGenerator.addChild parentFolder, folderElement
xmlGenerator.addAttribute folderElement, "id", rsFolder("id")
xmlGenerator.addAttribute folderElement, "parent",
rsFolder("parentId")
xmlGenerator.addChild folderElement, titleElement
xmlGenerator.addChild folderElement, imageElement
xmlGenerator.addChild folderElement, imageOpenElement
do while not rsFolder.EOF and folderId <> ""

traverseFolderNodes rsFolder("id"), folderElement
rsFolder.moveNext()
loop
end if
end function

public sub createElement(elementName, byRef element)
Set element = objDom.createElement(elementName)
end sub

</snip>
--------------------------------------------------------------------------------

The error message I am getting is:

"Inserting a Node or its ancestor under itself is not allowed."

Any words of wisdom would be appreciated
Jul 20 '05 #1
0 1637

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Max M | last post by:
I guess that the best approach is calling a shell tool with something like os.popen(). But I cannot seem to find any free tools. Winzip has a command line option, but for registered users only....
1
by: Piet | last post by:
Hi there. I have a problem when working with a wxTreeCtrl. I would like to expand all branches of a sepcific position in a tree with a single command. Since there does not appear to be such a...
0
by: Dinesh | last post by:
Hi, I have two tables 'master' and 'child', the master is the master table for all nodes in all trees. To get children of any node, we need to go to the 'child' table to get the nodeid of the...
2
by: melo | last post by:
Hello, I've been struggling with a function(s) to recursively set all folders and files to NOT read-only. So, I thought I'd post this message. What I need to do is: given a starting path, I...
10
by: Dan Nash | last post by:
Hi peeps.. Im using the TreeView control from IE COntrols to create a directory structure, and trying to do it recursively. The code works, but my question is simply how can I make the subdirs...
2
by: graphicsxp | last post by:
Hi, I have the following records stored in the database : TableName: Folder { FolderID, FolderName, TopLevel} TableName: FolderRelationship { ParentID, ChildID} This describes a folder...
2
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: ...
9
by: smoothoperator12 | last post by:
Hi all, I have spent hours trying to figure out where I have went wrong with my code for my recursive function to list all the files in a directory, and all of the files in all of its...
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.