我们如何将XML文件内容添加到另一个XML文件(在特定位置)

时间:2013-07-05 09:54:08

标签: xml xslt

我想使用Xslt

将XML文件内容添加到另一个XML文件中

我们怎么做?

2 个答案:

答案 0 :(得分:2)

使用document()函数加载其他XML文档。如果您只想在输出树中逐字插入第二个文档的内容,可以使用

<xsl:copy-of select="document('otherfile.xml')/*" />

答案 1 :(得分:2)

要添加到Ian Roberts的回答中,如果要将第二个文档作为最外层元素的最后一个子项插入,请执行以下操作“:

<xsl:template match="/*">
  <xsl:copy>
    <xsl:copy-of select="@*, node()"/>
    <xsl:copy-of select="document('otherfile.xml')"/>
  </xsl:copy>
</xsl:template>