【发布时间】:2013-10-15 05:42:19
【问题描述】:
我正在尝试为此 xml 创建一个子 XML 元素:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
</configuration>
我使用这个 PowerShell 脚本:
[xml] $doc = Get-Content($filePath)
$child = $doc.CreateElement("newElement")
$doc.configuration.AppendChild($child)
我有一个错误: 方法调用失败,因为 [System.String] 不包含名为 'AppendChild'。
【问题讨论】:
-
这一定是 powershell 中最愚蠢的“怪癖”。
-
这在 powershell 6 中运行良好。(在 6.2 上测试)
标签: xml powershell