【发布时间】:2010-06-04 07:38:30
【问题描述】:
我有一个非常大的 XML 文件目录,其结构如下:
file1.xml:
<root>
<EmployeeInfo attr="one" />
<EmployeeInfo attr="two" />
<EmployeeInfo attr="three" />
</root>
file2.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 方法 是什么?
干杯, 乔金
【问题讨论】:
标签: xml powershell powershell-2.0