Saturday, June 9, 2012

Merger 2 File XML Menggunakan Visual Basic 6.0

Private Sub AddPostNew(XMLSource As String, XMLDestination As String) 

Dim
strText As String
Dim
strPost As String

Dim
domFree As FreeThreadedDOMDocument60
Dim domApt As DOMDocument60
Dim node As IXMLDOMNode
Dim clone As IXMLDOMNode
Dim msg As String

msg = ""
Set domFree = New FreeThreadedDOMDocument60
Set domApt = New DOMDocument60

domApt.async = False
If False =
domApt.loadXML(XMLDestination) Then
MsgBox "can't load doc1.xml"
Exit Sub
End If

domFree.async = False
If False =
domFree.loadXML(XMLSource) Then
MsgBox "can't load doc2.xml"
Exit Sub
End If

Dim
nodeId As IXMLDOMAttribute
Set node = domFree.documentElement

Set
clone = domApt.importNode(node, True)

domApt.documentElement.appendChild clone
domApt.documentElement.appendChild domApt.createTextNode(vbNewLine)

Set
node = Nothing
Set clone = Nothing

domApt.save strPathXML

End Sub