I am traversing a HTML document using javascript DOM. I want make a list (an array actually) of all nodes/elements and their values. 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 something.
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?