XPATH issue in C# and PowerShell

By : George2
Source: Stackoverflow.com

I have the following XML file and I want to print out the baseAddress value, then change the value and write update to the same XML file.

My problem is I am using the following scripts in PowerShell to manipulate, and seems the related value could not be retrieved. I think the reason may be there is a sign '.' in the element name "system.serviceModel", which PowerShell thinks I want to retrieve serviceModel sub-element under system? Any ideas how to retrieve the correct value for baseAddress?

$FooConfig = [xml](get-content .\Foo.exe.config -ErrorAction:stop)

      <service name="FooImpl" behaviorConfiguration="mexServiceBehavior">
            <add baseAddress="http://localhost:9090/Foo" />

thanks in advance, George

By : George2


If you put quotes around the element name with a "." you can get it.



This video can help you solving your question :)
By: admin