Hi Dean,
One easy way is to use recursion. Create a function for the code in your If block. Call this function and pass it the oNodeList element. Then, add an Else If block parallel to the NODE_ELEMENT check that includes a call to this function with the ONode as the parameter. Recursion means successively calling into the same function. Of course recursion is not a great coding practice because it can cause infinite recursion if you are not careful with conditions. In addition, it uses up a lot of stack space. However, it does result in the least amount of code. Good luck!
Patrick Halstead
Project Manager at Qdabra