且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

具有命名空间的元素的 XPath

更新时间:2023-11-24 16:55:58

正确的xpath是

XPATH:

/configuration/runtime/ns:assemblyBinding/ns:dependentAssembly[ns:assemblyIdentity[@name='System.Reactive.Linq']]/ns:bindingRedirect/@newVersion

其中 ns 是命名空间 urn:schemas-microsoft-com:asm.v1

我在项目文件的 MSBuild 任务中使用 XmlPoke 任务来修改绑定重定向.与 XmlPoke 任务一起,代码如下所示:

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:

 <XmlPoke XmlInputPath="$(DestXmlFiles)" 
          Namespaces="&lt;Namespace Prefix='ns' Uri='urn:schemas-microsoft-com:asm.v1' Name='DoNotKnowWhatThisIsFor-ButItIsRequired' /&gt;"
          Query="/configuration/runtime/ns:assemblyBinding/ns:dependentAssembly[ns:assemblyIdentity[@name='System.Reactive.Linq']]/ns:bindingRedirect/@newVersion"
          Value="$(BUILD_NUMBER)"/>