我想替换所有表达式=
的内容如果没有与'' Where'匹配的重复节点,我在下面测试的代码是有效的。条件。
但是如果有重复项,则错误是'在此对象上找不到属性表达式':
下面是替换表达式=:
的powershell代码param([String]$twb_path='D:\auto\',
[String]$twb_name='Location_Geo (3).twb',
[String]$replace_var='test@email',
[String]$action_name='Click to go to Support')
$xml=New-Object System.XML.XMLDocument
$xml.Load($twb_path+'temp\wb\'+$twb_name)
$xml.GetType().FullName
Select-Xml -Xml $xml -XPath "./workbook" | Select-Object -ExpandProperty Node
$node = $xml.workbook.actions.action | Where-Object {$_.caption -eq $action_name}
$node.link.expression = $replace_var
以下是XML的外观:
<action caption="Click to go to Support" name="[Action13]">
<activation type="on-select" />
<source dashboard="003-A2: Detailed List " type="sheet" worksheet="Support Icon" />
<link caption="Click to go to Support" expression="mailto: emailadd" />
</action>
<action caption="Click to go to Support" name="[Action14]">
<activation type="on-select" />
<source dashboard="some dashboard" type="sheet" worksheet="Support Icon" />
<link caption="Click to go to Support" expression="mailto: emailadd" />
</action>