Solved

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

Posted on 2014-04-21
1
582 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
1 Comment
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# - Read Through Non-Standard XML File 12 87
xml xsd validation free tool to download 10 76
XML & .net 5 40
Excel file not created as expected 7 46
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…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

937 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now