I am trying to take 2 large XML files and combine them without any duplicate nodes. The code below is as far as I have gotten. I have loaded the 2 files but in the 'For' loop below I am trying to populate an array with all of the 'item' nodes, it bombs. Can anyone give me a nudge with this?


<!-- A -->

<item term="AAA" def="Not the American Automobile Association"  />

<item term="ABCCC" def="Definition 1" />

<item term="ABP" def="This means blah" />

Dim description, filepath
Set xmlDoc1 = CreateObject("Msxml2.DOMDocument")
If xmlDoc1.load("glossary/glossary_data.xml")Then 
    'MsgBox "SUCCESS loading XML File"  
    MsgBox "ERROR loading XML File"   'Error message if file fails to load
End If  

Set xmlDoc2 = CreateObject("Msxml2.DOMDocument")
xmlDoc2.load("glossary2/glossary_data.xml")'file 2
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
Dim oneElement
'Dim count = xmlDoc1.documentElement.selectNodes("item").length
Dim elementArray(2)

'for each item in xmlDoc1.documentElement.selectNodes("item")
For i = 0 to xmlDoc1.documentElement.selectNodes("item").length	
	Set objRoot = xmlDoc.createElement("item")
	objRoot.setAttribute "term", "This is the term"
	objRoot.setAttribute "def", "This is the definition"
	elementArray(i) = objRoot

xmlDoc.appendChild objRoot

Set objIntro = xmlDoc.createProcessingInstruction("xml","version='1.0'")  
xmlDoc.insertBefore objIntro,xmlDoc.childNodes(0)