Powershell SetAttribute 添加回车换行符

问题描述

我有一个 xml:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    <supportedRuntime version="v4.0" />
    <supportedRuntime version="v2.0.50727" />
  </startup>
  <appSettings>
    <add value="020_8" />
  </appSettings>
</configuration>

我正在尝试修改“值”属性。这是powershell脚本:

param($configfilepath,$buildrev)
[string]$foldername = Out-String -InputObject $buildrev
$error.clear()
$xml = New-Object xml
$xml.Load($configfilepath)
$xml.configuration.appSettings.add.SetAttribute('value',$foldername)
$xml.Save($configfilepath)

这确实将 xml 属性修改为:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    <supportedRuntime version="v4.0" />
    <supportedRuntime version="v2.0.50727" />
  </startup>
  <appSettings>
    <add value="025&#xD;&#xA;" />
  </appSettings>
</configuration>

我想要的值是 025 但它也添加

"&#xD;&#xA;"

这不是我想要的。我该如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)