Is there a way within a single XSLT file to first open one XML file and extract an element with children and then stuff that element into a second XML file?
If it can't be done in one XSLT, then my choice of languages would be vb script.
I have seen many different examples here, but I am just confused and don't understand the majority of them.
Here is the XSL i have working for extracting a node from XML1:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="xml"
omit-xml-declaration="yes"
indent="yes"
encoding="ISO-8859-1"/>
<xsl:template match="/">
<xsl:copy-of select="root/Collection/Item/." />
</xsl:template>
</xsl:stylesheet>
I want to take the resulting Item and append it to XML2 in the same XPATH, root/Collection.
I have a vb script from this answer How to save XML to a file (Thank you Andrew Cooper) that returns the XML to a memvar.
XML1:
<root>
<collection1>
<item attr1, attr2...> ---this is what I am getting
<more>
</more>
</item>
<collection1>
<collection2>
<item attr1, attr2...>
<more>
</more>
</item>
<collection2>
...
<collection_n>
<item attr1, attr2...>
<more>
</more>
</item>
<collection_n>
</root>
XML2:
<root>
<collection1>
<item attr1, attr2...>
<more>
</more>
</item>
---- i want to insert node from XML1 here, only in collection1
<collection1>
<collection2>
<item attr1, attr2...>
<more>
</more>
</item>
<collection2>
...
<collection_n>
<item attr1, attr2...>
<more>
</more>
</item>
<collection_n>
</root>
so the new XML2:
<root>
<collection1>
<item attr1, attr2...>
<more>
</more>
</item>
<item attr1, attr2...>
<more>
</more>
</item>
<collection1>
<collection2>
<item attr1, attr2...>
<more>
</more>
</item>
<collection2>
...
<collection_n>
<item attr1, attr2...>
<more>
</more>
</item>
<collection_n>
</root>