Insert XML Into Another XML Document

Insert XML Into Another XML Document

Question:

Is there an easy and efficient way to insert an XML document into another XML template? The insertion point can be before, between, or after specified nodes.

Answer:

Sure. I do this all the time. If you’re going from a DOM-based solution, you can incorporate one XML structure into another through the use of appendChild and cloneNode. For example:

dim parentDocdim childDocdim insertionNodeset parentDoc=createObject("Microsoft.XMLDOM")set childDoc=createObject("Microsoft.XMLDOM")parentDoc.load "myXMLDoc.xml"childDoc.load "myChildXMLDoc.xml"set insertionNode=parentDoc.selectSingleNode("//some/arbitrary/path")insertionNode.appendChild childDoc.documentElement

In this case, you load in two documents, select the node you want to attach the child document to, then append the document element of the child document as a child to that node. There is similarly an .insertBefore(nodePos) method that can insert the new document into the node along with any other children that the node happens to have.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across