xpath help

  • Thread starter Thread starter Frank Rizzo
  • Start date Start date
F

Frank Rizzo

Hello, I am trying to change app.config via xpath (in a nant script).

The app.config is as follows:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="CRMMetadataServiceUrl" value="devLANI-RF1"/>
</appSettings>
</configuration>

The following xpath

"configuration/appSettings/add[@key = 'CRMMetadataServiceUrl']/@value"


locates the key fine if there is no xmlns attribute on the
'configuration' element, but won't work if the attribute is there. How
can I get to the key if the attribute is there?

Thanks.
 
Frank said:
Hello, I am trying to change app.config via xpath (in a nant script).

The app.config is as follows:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="CRMMetadataServiceUrl" value="devLANI-RF1"/>
</appSettings>
</configuration>

The following xpath

"configuration/appSettings/add[@key = 'CRMMetadataServiceUrl']/@value"


locates the key fine if there is no xmlns attribute on the
'configuration' element, but won't work if the attribute is there. How
can I get to the key if the attribute is there?

Thanks.

if the attribute of the configuration tag is always the same, you can do
this:

configuration[@xmlns =
"http://schemas.microsoft.com/.NetConfiguration/v2.0"]/appsettings/add[@key
= 'CRMMetadataServiceUrl']/@value

You could also try this:
/appsettings/add[@key = 'CRMMetadataServiceUrl']/@value

i believe in that example, the leading slash means "root element" no
matter what the root element is.
 
Back
Top