我有下面需要编辑的 XML 文件。
<?xml version="1.0"?>
<rdwastr:strings xmlns:rdwastr="urn:microsoft.com:rdwastrings">
<string id="PageTitle">RD Web Access</string>
<string id="NoScriptWarning">
<p id="NoScript1">RD Web Access requires JScript. This Web browser either does not support JScript, or scripts are being blocked.</p>
<br/>
<br/>
<p id="NoScript2">To find out whether your browser supports JScript, or to allow scripts, see the browser's online Help.</p>
</string>
<string id="HeadingRDWA">RD Web Access</string>
<string id="HeadingApplicationName">RemoteApp and Desktop Connection</string>
.
.
.
<string id="PrivateComputer">I am using a private computer that complies with my organization's security policy.</string>
<string id="MoreInformation">More information...</string>
<string id="PrivateMore">By selecting this option you can save your credentials so that they can be used in the future when connecting to these programs. Before you select this option, please ensure that saving your credentials is in compliance with your organization's security policy.</string>
<string id="HideMore">Hide additional information...</string>
</rdwastr:strings>
网上有几个例子,但到目前为止我还没有得到结果,这是我最后尝试的。显然分号可能是个问题。
$xml = [xml](Get-Content \\$client.xyz.com\C$\Windows\Web\RDWeb\Pages\en-US\RDWAStrings.xml)
$node = $xml."rdwastr:strings".string | where {$_.id -eq 'HeadingApplicationName'}
Write-Host $node
$node.Value = "whatever"
Write-Host 不返回任何内容,因此我假设前面的语句不返回任何内容并将其分配给节点。我该如何解决这个问题?
至少可以说,我在使用 XML 方面的经验是有限的,但是像这样的东西怎么样:
似乎在我有限的测试中工作......