我有以下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