0
在單個XSLT文件中是否有辦法先打開一個XML文件並使用子元素提取元素,然後將該元素填充到第二個XML文件中?從一個XML文件中提取元素並將其填充到另一個XML文件
如果它不能在一個XSLT中完成,那麼我選擇的語言將是VB腳本。
我在這裏看到很多不同的例子,但我只是困惑,並不瞭解他們中的大多數。
這裏是我的工作從XML1提取節點的XSL:
<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>
我要承擔由此產生的項目並將其追加到XML2在同一XPATH,根/集。
我有一個這個答案的腳本How to save XML to a file(謝謝你安德魯庫珀),將XML返回到一個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>
因此新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>
謝謝。我沒有看到那一個。這些問題有很多,但並非所有問題都很容易找到。再次感謝。 – dashrader