What is the XPATH for attribute newVersion
in the element
<dependentAssembly>
<assemblyIdentity name="System.Reactive.Linq" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" />
</dependentAssembly>
I have tried my best to do it by myself. But don't know how to get XPATH for elements with namespace. Its very confusing. Somebody please provide me a XPATH.
XPATH which I came up with is
/configuration/runtime/assemblyBinding/dependentAssembly[2]/bindingRedirect[@newVersion='2.2.5.0']/@newVersion
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<legacyUnhandledExceptionPolicy enabled="1" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect name="Test1" oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reactive.Linq" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" />
</dependentAssembly>
</assemblyBinding>
The right xpath is
XPATH:
/configuration/runtime/ns:assemblyBinding/ns:dependentAssembly[ns:assemblyIdentity[@name='System.Reactive.Linq']]/ns:bindingRedirect/@newVersion
Where
ns
is the namespaceurn:schemas-microsoft-com:asm.v1
I use a XmlPoke Task in the MSBuild tasks in the project file to modify the binding redirect. Together with a XmlPoke Task the code goes like this:
In XSLT 1.0 you must declare namespaces with a prefix in order to be able to use them in XPath.
For example (wrapped for legibility):
However, you don't have to specify the entire path, you could take shortcuts: