Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2005, 02:27 PM
Authorized User
 
Join Date: Sep 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML using MSXML2.DOMDocument object

Hi everyone,

I am very new to VBA and XML in general.

I need some help with MSXML2.DOMDocument object. I am using VBA and have the following scenario.

I have an XML structure as follows:

<SomeRootElement>
<Input>
</Input>
</SomeRootElement>

Then I have another XML structure as follows:
<Output>
<SomeElement>
</SomeElement>
</Output>

Now what I want to do is combine these XML structures, so I have:
<SomeRootElement>
<Input>
</Input>
<Output>
<SomeElement>
</SomeElement>
</Output>
</SomeRootElement>

basically, add the second XML structure as a child to the root element.

How can I do this using VBA?

Thanks!
Cheers!
xargon

 
Old May 26th, 2006, 08:51 AM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I realize this is an old post but I've been working on this subject and this was the first hit on Google. Need to reference Microsoft XML in your project.

Sub MergeXML()

   'Define
   Dim oXml As New MSXML2.DOMDocument
   Dim oXml2 As New MSXML2.DOMDocument

   'Assign
   oXml.loadXML ("<SomeRootElement><Input></Input></SomeRootElement>")
   oXml2.loadXML ("<Output><SomeElement></SomeElement></Output>")
   'or assign via file
   'oXml.Load("c:\Xml.xml")
   'oXml2.Load("c:\Xml2.xml")

   'Process
   oXml.FirstChild.appendChild oXml2.selectSingleNode("//Output")

   'Destroy
   oXml.Save ("c:\NewXml.xml")
   Set oXml2 = Nothing
   Set oXml = Nothing

End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
DomDocument is not working for me nikul PHP How-To 0 December 24th, 2007 07:47 AM
Object Required Error When Using MSXML2?!?! kevorkian XML 16 January 15th, 2007 04:34 PM
MSXML2 Type mismatch desperado1306 Excel VBA 0 June 2nd, 2006 12:18 PM
MSXML2.ServerXMLHTTP help appreciated!! Steven1984 Classic ASP Professional 0 June 4th, 2005 12:49 PM
MSXML2.XMLHTTP Caching? spraguey Javascript 2 December 6th, 2004 09:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.