Powershell - 创建 XML 文件



Cmdlet

New-Item Cmdlet 用于创建 xml 文件和 Set-Content Cmdlet 用于将内容放入其中。

步骤 1

在此示例中,我们创建一个名为 test.xml 的 xml 文件

在 PowerShell ISE 控制台中键入以下命令

New-Item D:\temp\test\test.xml -ItemType File

您可以看到在 D:\temp\test 目录中创建的 test.xml。

步骤 2

在此示例中,我们将内容添加到 test.xml 中。

在 PowerShell ISE 控制台中键入以下命令

Set-Content D:\temp\test\test.xml '<title>Welcome to TutorialsPoint</title>'

步骤 3

在此示例中,我们读取 test.xml 的内容。

Get-Content D:\temp\test\test.xml

输出

您可以在 PowerShell 控制台中看到以下输出。

<title>Welcome to TutorialsPoint</title>
powershell_files_io.htm
广告
© . All rights reserved.