我有一个非常大的XML文件目录,其结构如下:
file1.xml:
现在我正在寻找一种简单的方法将这些文件 (*.xml) 合并成一个输出文件:
我在考虑使用像这样的纯XSLT:
这可以工作,但不如我想要的灵活。作为一个渴望学习在PowerShell中使用XML的最佳实践的新手(版本2),我想知道将XML文档的结构合并为一个的最简单、最纯粹的PowerShell方式是什么?
祝好, Joakim
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中使用XML的最佳实践的新手(版本2),我想知道将XML文档的结构合并为一个的最简单、最纯粹的PowerShell方式是什么?
祝好, Joakim
$finalXml += $xml.root.InnerXml
除此之外,一切都运作得很好 :) - Vingt_centimes