title: XPath - preceding sibling contains an element check
body: <p>I have the following simplified HTML from a webpage...</p>
  
  <pre><code>&lt;div class="row import-entity"&gt;
      &lt;div class="col-md-11"&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-md-3"&gt;
                  &lt;span class="mandatory"&gt;&lt;/span&gt;
              &lt;/div&gt;
              &lt;div class="col-md-3"&gt;
                  &lt;input id="ImportTemplateEntities_2918.Header" type="hidden"&gt;&lt;/input&gt;
                  &lt;input id="ImportTemplateEntities_5923.Header"&gt;&lt;/input&gt;
              &lt;/div&gt;
              &lt;div class="col-md-3"&gt;
                  &lt;input id="ImportTemplateEntities_1234.Column"&gt;&lt;/input&gt;
              &lt;/div&gt;
              &lt;div class="col-md-3"&gt;&lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-md-3"&gt;&lt;/div&gt;
              &lt;div class="col-md-3"&gt;
                  &lt;input id="ImportTemplateEntities_9182.Header" type="hidden"&gt;&lt;/input&gt;
                  &lt;input id="ImportTemplateEntities_2834.Header"&gt;&lt;/input&gt;
              &lt;/div&gt;
              &lt;div class="col-md-3"&gt;
                  &lt;input id="ImportTemplateEntities_1243.Column"&gt;&lt;/input&gt;
              &lt;/div&gt;
              &lt;div class="col-md-3"&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>With a requirement for the following XPath selection criteria...</p>
  
  <ul>
  <li>An <strong>input</strong> tag that is within a <strong>col-md-3</strong> <strong>div</strong> that is immediately after a <strong>col-md-3</strong> <strong>div</strong> that contains a <strong>span</strong> with class = mandatory</li>
  <li><strong>input</strong> tag shouldn't be hidden</li>
  </ul>
  
  <p>The following element from the HTML above matches the search criteria</p>
  
  <pre><code>&lt;input id="ImportTemplateEntities_5923.Header"&gt;&lt;/input&gt;
  </code></pre>
  
  <p>(Note that the numerical value in the ID is assigned dynamically, and won't be known to me when searching the document.)</p>
  
  <p>Before adding any sort of preceding sibling check this is what I have....</p>
  
  <pre><code>//input[contains(@id,'ImportTemplateEntities')][contains(@id,'Header')][not(contains(@type,'hidden'))]
  </code></pre>
  
  <p>How would I edit this to add a condition for checking whether the preceding sibling <code>div</code> contains a <code>span</code> with <code>class</code> = <code>mandatory</code>?</p>