Using the same ID ist verboten. :-)
You could use either document.getElementsByTagName("name") and then iterate the NodeList (list.item(0), list.item(1), etc.), or just get the first one by ID, then iterate the DOM from there (node.nextSibling(), etc.).