我有一个非常大的 XML 文件目录,其结构如下:
文件 1.xml:
<root>
<EmployeeInfo attr="one" />
<EmployeeInfo attr="two" />
<EmployeeInfo attr="three" />
</root>
文件 2.xml:
<root>
<EmployeeInfo attr="four" />
<EmployeeInfo attr="five" />
<EmployeeInfo attr="six" />
</root>
现在我正在寻找一种将这些文件 (*.xml) 文件合并到一个输出文件中的简单方法:
<root>
<EmployeeInfo attr="one" />
<EmployeeInfo attr="two" />
<EmployeeInfo attr="three" />
<EmployeeInfo attr="four" />
<EmployeeInfo attr="five" />
<EmployeeInfo attr="six" />
</root>
我正在考虑使用纯 XSLT,例如这个:
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Container>
<xsl:copy-of select="document('file1.xml')"/>
<xsl:copy-of select="document('file2.xml')"/>
</Container>
</xsl:template>
</xsl:stylesheet>
这有效,但不像我想要的那样灵活。作为 PowerShell(第 2 版)的新手,渴望学习在 PowerShell 中使用 XML 的新最佳实践,我想知道将 XML 文档的结构合并为一个的最简单、最纯粹的PowerShell 方法是什么?
干杯,乔金