Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to Merge XML files 1

Status
Not open for further replies.

roblay22

IS-IT--Management
Aug 11, 2004
28
0
0
GB
Hi All, I'm a network engineer but I have limited scripting knowledge. I have 2 xml files, and i need to merge the 2. Is there a way of using a vbscript which could be run as a windows startup script to merge the contents of an xml file on a server and an xml file on the local machine which the script is running on??

Any help would be really helpful.

Thanks
 
Check out ms article.

The script version will be this, following as closely as possible to the article. (You have to use progid name instead and use createobject method for vbs.)
[tt]
Dim doc1 'As MSXML2.DOMDocument30
Dim doc2 'As MSXML2.DOMDocument30
Dim doc2Node 'As MSXML2.IXMLDOMNode

Set doc1 = createobject("MSXML2.DOMDocument.3.0")
Set doc2 = createobject("MSXML2.DOMDocument.3.0")

doc1.Load "d:\xmlbooks1.xml"
doc2.Load "d:\xmlbooks2.xml"

For Each doc2Node In doc2.documentElement.childNodes
doc1.documentElement.appendChild doc2Node
Next

MsgBox doc1.xml

doc1.save "d:\AllXMLBooks.xml"
[/tt]
 
Like it, Love it, want more of it.
have a star.


if it is to be it's up to me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top