title: Needing help with XSLT for-each using XPATH
body: <p>I am working on a project that uses XSLT to transform an HTML string to extract some specific values. Can you please look at the HTML/XSLT below and see what it is that I am doing wrong? </p>
  
  <p>BTW In the HTML below I need to extract value from <code>&lt;a&gt;</code> which says "something" (XPATH = //div[@id='result']/div[2]/div[1]/a[1]):</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;&lt;/head&gt;
      &lt;body&gt;
          &lt;div&gt;
              &lt;div id="whatever"&gt;
                  &lt;!--other stuff--&gt;
              &lt;/div&gt;
              &lt;div id="whatever2"&gt;
                  &lt;!--other stuff--&gt;
                  &lt;div&gt;
                      &lt;div class='listtable'&gt;
                          &lt;div&gt;
                              &lt;div id="result"&gt;
                                  &lt;div class="ignore"&gt;
                                      &lt;!--other stuff--&gt;
                                  &lt;/div&gt;
                                  &lt;div&gt;
                                      &lt;div&gt;
                                          &lt;a&gt;something&lt;/a&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                          &lt;div&gt;
                              &lt;div id="result"&gt;
                                  &lt;div class="ignore"&gt;
                                      &lt;!--other stuff--&gt;
                                  &lt;/div&gt;
                                  &lt;div&gt;
                                      &lt;div&gt;
                                          &lt;a&gt;something&lt;/a&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>so, the XSLT i came up with looks like this but it doesnt work ...</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
    &lt;xsl:template match="/"&gt;
        &lt;html&gt;
        &lt;body&gt;
        &lt;h2&gt;My Link Collection&lt;/h2&gt;
          &lt;table border="1"&gt;
            &lt;tr bgcolor="#9acd32"&gt;
              &lt;th&gt;Title&lt;/th&gt;
            &lt;/tr&gt;
            &lt;xsl:for-each select="//div[@id='result']"&gt;
            &lt;tr&gt;
              &lt;td&gt;&lt;xsl:value-of select="/div[2]/div[1]/a[1]"/&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;/xsl:for-each&gt;
          &lt;/table&gt;
        &lt;/body&gt;
        &lt;/html&gt;
      &lt;/xsl:template&gt;
      &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>P.S.: I have worked with XPATHS before but I have no experience with XSLT and for whatever reason Visual Studio crashes when I try to debug so I have no clue what went wrong here.</p>
  
  <p>Thanks for your help!</p>