.appendChild help

I have an xml document that has the following format (I'm leaving out the details because they aren't pertinent to my question):
<Recordsets>
   <Group1>....</Group1>
</Recordsets>

I have another xml document that has the following format:
<Group2>...</Group2>

What I need to do is add the second xml document to the first xml document so I get this:
<Recordsets>
  <Group1>...</Group1>
  <Group2>...</Group2>
</Recordsets>

It doesn't matter whether Group2 comes before or after Group1.  I'm using the following in VB 6:
Call xmlResponse.documentElement.appendChild(xmlAssigned)

xmlResponse is document 1 and xmlAssigned is document 2.  THis gives me the following which is close but not quite what I wanted:

<Recordsets>
  <Group1>...</Group1>
</Recordsets>
<Group2>...</Group2>

Can anyone help me with the correct function I need to use to get what I want?
dyaroshAsked:
Who is Participating?
 
dyaroshConnect With a Mentor Author Commented:
I finally discovered the correct syntax:

 For iLoop = 0 To xmlAssigned.childNodes.length - 1
        Call xmlResponse.appendChild(xmlAssigned.childNodes(0))
    Next
0
 
Hawkvalley1Commented:
Dim g2 As XmlNode = xmlResponse.CreateElement("Group2")
'add more stuff to g2 element
xmlResponse.SelectSingleNode("//RecordSets").Appendchild(g2)

Open in new window

0
 
dyaroshAuthor Commented:
I received an error: object doesn't support this object or method

Here is what I have:

xmlResponse.documentElement.selectSingleNode("//RecordSets").appendChild (xmlAssigned)

Any thoughts?
0
 
dyaroshAuthor Commented:
I was finally able to find the right combination plus I didn't receive any more feedback from the experts.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.