AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 654466
Accepted
user2629636
user2629636
Asked: 2014-12-24 10:26:42 +0800 CST2014-12-24 10:26:42 +0800 CST 2014-12-24 10:26:42 +0800 CST

从 powershell 编辑 XML 文件

  • 772

我有下面需要编辑的 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 不返回任何内容,因此我假设前面的语句不返回任何内容并将其分配给节点。我该如何解决这个问题?

powershell
  • 1 1 个回答
  • 4247 Views

1 个回答

  • Voted
  1. Best Answer
    Hunter Eidson
    2014-12-24T10:52:19+08:002014-12-24T10:52:19+08:00

    至少可以说,我在使用 XML 方面的经验是有限的,但是像这样的东西怎么样:

    $node = $xml.strings.string | where { $_.id -eq "HeadingApplicationName" }
    Write-Host $node.'#text'
    $node.'#text' = "whatever"
    

    似乎在我有限的测试中工作......

    • 3

相关问题

  • 资源锁和电源外壳

  • 脚本 - 如何断开远程桌面会话?

  • 如何限制向通讯组发送到外部地址?

  • Powershell对值与数组的作用不同?

  • Windows Powershell Vim 键绑定

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve