title: Finding all classes "B" in Class "A" in XPath
body: <p>I have trouble finding the right XPath for a program I am writing.
  The XML is something like this:</p>
  
  <pre><code>&lt;root&gt;
      &lt;div class"XYZ"&gt;
          &lt;div&gt;
              &lt;div class = "abc"&gt;
                  &lt;a class = "important"&gt;Important Information - 1&lt;/a&gt;
              &lt;/div&gt;
              &lt;div class = "abc"&gt;
                  &lt;a class = "important"&gt;Important Information - 2&lt;/a&gt;
              &lt;/div&gt;
              &lt;div class = "abc"&gt;
                  &lt;a class = "important"&gt;Important Information - 3&lt;/a&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>So, as you can see, there is a class I need to go "XYZ" and in that class there are many classes named "abc". In reality there are more <code>&lt;div&gt;</code> in front of the class "abc".</p>
  
  <p>I need to get every "Important Information - X".</p>
  
  <p>My idea was </p>
  
  <pre><code>FindElements(By.XPath("//*[contains(@class,'XYZ')]/*[contains(@class,'important')]");
  </code></pre>
  
  <p>The problem why I can't just search for the class = "important" itself is, that there is another part in the document, which has the same class name but I don't need that information. Only the ones in the class "XYZ".</p>
  
  <p>When I only use:</p>
  
  <pre><code>FindElements(By.XPath("//*[contains(@class,'XYZ')]");
  </code></pre>
  
  <p>it works, but I get a lot of unimportant information too, since there is more stuff in the <code>&lt;div&gt;</code>s.</p>