gpt4 book ai didi

visual-studio-2010 - 转换 web.config 中的特定节点

转载 作者:行者123 更新时间:2023-12-02 12:53:05 26 4
gpt4 key购买 nike

我想使用 VS2010 web.config 转换功能,但我不确定应该使用 XPath 来替换某个值。

我定义了以下客户端服务端点:

<client>
<endpoint name="IMyService"
address="net.tcp://x.x.x.x:xx/MySvc"
binding="netTcpBinding"
bindingConfiguration="..."
contract="..."
>
<identity>
<servicePrincipalName value="host/testMachine.domain.com" />
</identity>
</endpoint>
</client>

我想将 servicePrincipalName 节点替换为以下值。

<servicePrincipalName value="host/productionMachine.domain.com" />

由于可能定义了多个客户端端点,因此我更喜欢使用标识特定端点节点的 XPath(在本例中为 name="IMyService")。

所以在伪代码中,我需要这样做:

<servicePrincipalName value="host/productionMachine.domain.com" 
xdt:Transform="Replace"
xdt:Locator="Condition([containing endpoint node] @name='IMyService')"
/>

有人可以告诉我那些方括号所在的位置应该是什么,或者告诉我一些替换该特定节点的其他时髦方法吗?

最佳答案

我将匹配并替换端点节点,如下所示:

<client>
<endpoint name="IMyService"
address="net.tcp://x.x.x.x:xx/MySvc"
binding="netTcpBinding"
bindingConfiguration="..."
contract="..."
xdt:Transform="Replace"
xdt:Locator="Match(name)"
>
<identity>
<servicePrincipalName value="host/productionMachine.domain.com" />
</identity>
</endpoint>
</client>

关于visual-studio-2010 - 转换 web.config 中的特定节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5481706/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com