title: XML Transform locate a node based on values in neighboring node
body: <p>I'm trying to set attributes for a node that has no key or name, but it neighboring node can be identified by its <code>name</code> attribute. But I' really struggling to come up with a locator expression to choose the correct node.</p>
  <p>The source xml is:</p>
  <pre><code>&lt;/configuration&gt;
      &lt;runtime&gt;
          &lt;assemblyBinding xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;
              ...
              &lt;dependentAssembly&gt;
                  &lt;assemblyIdentity name=&quot;System.Web.WebPages&quot; publicKeyToken=&quot;31bf3856ad364e35&quot; /&gt;
                  &lt;bindingRedirect oldVersion=&quot;0.0.0.0-3.0.0.0&quot; newVersion=&quot;3.0.0.0&quot; /&gt;
              &lt;/dependentAssembly&gt;
              ...
          &lt;/assemblyBinding&gt;
      &lt;/runtime&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p>and I tried</p>
  <pre><code>&lt;configuration xmlns:xdt=&quot;http://schemas.microsoft.com/XML-Document-Transform&quot;&gt;
      &lt;runtime&gt;
          &lt;assemblyBinding xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;
              ...
              &lt;dependentAssembly&gt;
                  &lt;bindingRedirect oldVersion=&quot;1.0.0.0-3.0.0.0&quot; xdt:Transform=&quot;SetAttributes&quot;
                      xdt:Locator=&quot;XPath(//../assemblyIdentity[@name='System.Web.WebPages'])&quot;/&gt;
              &lt;/dependentAssembly&gt;
              ...
          &lt;/assemblyBinding&gt;
      &lt;/runtime&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p>But it won't update the <code>oldVersion</code> attribute of the <code>bindingRedirect</code> node and if I omit the <code>xdt:Locator=&quot;...&quot;</code> entirely it changes the value for all <code>bindingRedirect</code> nodes.</p>
  <p><strong>Update:</strong>
  Using <a href="http://xpather.com/" rel="nofollow noreferrer">this</a> online xpath evaluator and the answer of Jack Fleeting I found an xpath expression which correctly selects the node I want</p>
  <pre><code>//dependentAssembly/assemblyIdentity[@name='System.Web.WebPages']/following-sibling::bindingRedirect
  </code></pre>
  <p>the problem now seams to be that the transform engine does not know how to handle this.
  I tried to use the transformations <code>Replace</code> and <code>SetAttributes</code>, none of which resulted in an update of the node.
  Any ideas.</p>