问题描述
|
我有一个XML文件,我正在尝试修改,并想将一个新节点添加到现有的配置文件中。我正在尝试使用多行xml语句,并使用AppendChild将其添加到XML文件中。
这是我到目前为止的内容,但出现错误:
[xml]$deliveryExtensionNode = @\"<Extension Name=`\"Database Delivery`\">
<Configuration>
<Reports>
<Report>Sample Report</Report>
</Reports>
</Configuration>
</Extension>
\"@
但是我遇到一个错误:
源文本中无法识别的标记。
在C:\\ Users \\ Develer \\ AppData \\ Local \\ Temp \\ dc32aea8-9f74-4d4f-8237-6219a492ab7a.ps1:17 char:33
+ [xml] $ deliveryExtensionNode = <<<< @ \“
我认为Powershell可以处理多行分配。我可以对以下内容执行相同的操作:
$y = @\"
This is a test.
This is another test
\"@
还是因为XML需要某些格式?
解决方法
@ \”必须位于其自己的行上,这样。
[xml]$deliveryExtensionNode = @\"
<Extension Name=`\"Database Delivery`\">
<Configuration>
<Reports>
<Report>Sample Report</Report>
</Reports>
</Configuration>
</Extension>
\"@