[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

.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?
0
dyarosh
Asked:
dyarosh
  • 3
1 Solution
 
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 finally discovered the correct syntax:

 For iLoop = 0 To xmlAssigned.childNodes.length - 1
        Call xmlResponse.appendChild(xmlAssigned.childNodes(0))
    Next
0
 
dyaroshAuthor Commented:
I was finally able to find the right combination plus I didn't receive any more feedback from the experts.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now