我有以下XML文件,我想打印出baseAddress值,然後更改該值並將更新寫入同一個XML文件。C#和PowerShell中的XPATH問題
我的問題是我在PowerShell中使用以下腳本來操作,似乎無法檢索相關值。我認爲原因可能是有一個標誌'。'在元素名稱「system.serviceModel」中,哪個PowerShell認爲我想檢索系統下的serviceModel子元素?任何想法如何檢索baseAddress的正確值?
$FooConfig = [xml](get-content .\Foo.exe.config -ErrorAction:stop)
FooConfig.configuration.system.serviceModel.services.service.host.baseAddress
<configuration>
<system.serviceModel>
<services>
<service name="FooImpl" behaviorConfiguration="mexServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:9090/Foo" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
由於事先 喬治
嗨,喬治,什麼版本的PowerShell? – 2009-07-22 12:06:03
1.0,有什麼想法? – George2 2009-07-22 12:08:34