Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vb script/classic asp:  append xml documents to node of another xml document

Posted on 2014-04-21
1
Medium Priority
?
614 Views
Last Modified: 2014-04-22
In vb script / classic asp, How do I make it so I can append xml documents that are in an array to another xml Document as follows:

Set xmlDoc = CreateObject("Microsoft.XMLDOM")  
Set objRoot =  xmlDoc.createElement("runners")  :xmlDoc.appendChild objRoot  

Set objIntro =   xmlDoc.createProcessingInstruction ("xml","version='1.0'")  
xmlDoc.insertBefore objIntro,xmlDoc.childNodes(0)


for c__ = 1 to ubound(c_)
        'xarray is an array of xmldom documents
      objroot.appendchild xarray(c__)

next

This currently errs
0
Comment
Question by:KeithMcElroy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 total points
ID: 40014272
Here is some code I tested in VBA (because it's easier to debug than classic ASP).

Note that to me this doesn't make much sense without knowing what's in your arrays so I assumed they are the same length and there's nothing in array element 0 (looking at your for-loop code).
Dim c_(2), xarray(2)
Set xarray(1) = CreateObject("Microsoft.XMLDOM")
xarray(1).LoadXML "<root1><testdata1/></root1>"
Set xarray(2) = CreateObject("Microsoft.XMLDOM")
xarray(2).LoadXML "<root2><testdata2/></root2>"

Set xmldoc = CreateObject("Microsoft.XMLDOM")
Set objroot = xmldoc.createElement("runners"): xmldoc.appendchild objroot

Set objIntro = xmldoc.createProcessingInstruction("xml", "version='1.0'")
xmldoc.InsertBefore objIntro, xmldoc.ChildNodes(0)


For c__ = 1 To UBound(c_)
        'xarray is an array of xmldom documents
      objroot.appendchild xarray(c__).DocumentElement

Next

Open in new window

*edit: note the added ".DocumentElement"

result:
<?xml version="1.0"?>
<runners><root1><testdata1/></root1><root2><testdata2/></root2></runners>

Open in new window

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question