我有这个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"
写主机不返回任何东西,所以我假设前面的语句不返回任何东西,并将其分配给节点。 我如何解决这个问题?
我用XML来玩游戏的经验是有限的,至less可以这样说:
$node = $xml.strings.string | where { $_.id -eq "HeadingApplicationName" } Write-Host $node.'#text' $node.'#text' = "whatever"
似乎在我有限的testing工作…