If you are not already, you might want to hide the element you are creating nodes in, and only show it at the end of your loop.

E.g. set display:none; on it while you are working on it, and then switch back to display:block; (or whichever it is) afterwards.

Update: Actually, you don't even need to hide it, though that's one way to do it. The cleaner way is to wait with adding your table to the document until you finish adding all nodes to it, and then only add it to the body afterwards.