I am traversing a HTML document using javascript DOM. I want make a list (an array actually) of all nodes/elements and thier values. On w3schools website i found a script for traversing DOM but how do i store each node value in an array. I can't seem to find the unique identifier for a node. Anyone has any pointers? I was thinking of xpath or sumthing.

Is it a good idea to consider xpath for node as the unique identifier. If so how do i get xpath of a element while traversing the DOM.

Thanks in advance for your help