Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML 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 March 5th, 2007, 03:00 AM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Append XML1 as an element in XML2

Hi all,
I have two seperate xmls.XML1 =
<ABRQ>
    <SCHOOL>
         <NAME></NAME>
         <ADDRESS></ADDRESS>
         <TYPE></TYPE>
    </SCHOOL>
</ABRQ>

and xml2 =

<STUDENT>
     <NAME></NAME>
     <AGE></AGE>
     <ADDRESS></ADDRESS>
<STUDENT>

i want to add xml2 as child element in xml1 ie i want the output as ...

<ABRQ>
    <SCHOOL>
         <NAME></NAME>
         <ADDRESS></ADDRESS>
         <TYPE></TYPE>
    </SCHOOL>
    <STUDENT>
         <NAME></NAME>
         <AGE></AGE>
         <ADDRESS></ADDRESS>
    <STUDENT>
</ABRQ>

HOW DO WE DO IT USING VBSCRIPTING LANGUAGE


 
Old March 5th, 2007, 05:08 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Assuming you have the basic knowledge to load XML using MSXML (if you don't download the MSXML 6.0 Core Components and install the SDK) then the steps are:
  • Load the first document into a DomDocument, Dom1.
  • Load the second document into a DomDocument, Dom2
  • Create a copy of the desired node in the Dom2. If you're using MSXML 5.0 or greater use Set node = Dom1.ImportNode(Dom2.DocumentElement, true). If you are using a version lower than 5.0 use Set node = Dom2.DocumentElement.CloneNode(true).
  • Append the copied node: Dom1.DocumentElement.AppendChild(node)

--

Joe (Microsoft MVP - XML)
 
Old March 7th, 2007, 03:58 AM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Joe,
Thanks for your reply,
Actually we are trying to create xmls using QTPro9.0 testing tool which uses VBScript.
In that i followed the same steps but it didnt work it shows "GeneralError-identifier required" and points to the line -Dom2.DocumentElement.CloneNode(true).
Upto loading the document there was no problem.
we are using msxml4.0
ANy guesses why it is showing the error.

 
Old March 7th, 2007, 04:03 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Post the VBScript you used.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
Re-using Append Queries steve smart Access 1 May 17th, 2007 11:37 AM
translate element name to element name lexzeus XSLT 3 September 4th, 2006 09:04 AM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM
append to [email protected] VB Databases Basics 3 June 22nd, 2003 04:37 AM





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