Solved

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

Posted on 2014-04-21
1
589 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 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XML filtering Windows Event Viewer 10 69
ASP.NET reading ATOM 2 73
Need a modeling tool 2 40
MS Access VBA Object Variable Not Set. Can't figure this out. 11 44
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 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