title: Using Xpath axes to extract preceding element
body: <p>I'm trying to scrape data from a site with this structure below. I want to extract information in each of the <code>&lt;li id="entry"&gt;</code>, but both of the entries should also extract the category information from <code>&lt;li id="category"&gt; / &lt;h2&gt;</code></p>
  
  <pre><code>&lt;ul class="html-winners"&gt;
      &lt;li id="category"&gt;
          &lt;h2&gt;Redaktionell Print - Dagstidning&lt;/h2&gt;
          &lt;ul&gt;
              &lt;li id="entry"&gt;
                  &lt;div class="entry-info"&gt;
                      &lt;div class="block"&gt;
                          &lt;img src="bilder/tumme10/4.jpg" width="110" height="147"&gt;
                          &lt;span class="gold"&gt;Guld: Svenska Dagbladet&lt;/span&gt;&lt;br&gt;
                           &lt;strong&gt;&lt;strong&gt;Designer:&lt;/strong&gt;&lt;/strong&gt; Anna W Thurfjell och SvD:s medarbetare&lt;br&gt;
                         &lt;strong&gt;&lt;strong&gt;Motivering:&lt;/strong&gt;&lt;/strong&gt; "Konsekvent design som är lätt igenkänningsbar. Små förändringar förnyar ständigt och blldmotiven utnyttjas föredömligt."
                      &lt;/div&gt;
                  &lt;/div&gt;
            &lt;/li&gt;
            &lt;li  id="entry"&gt;
                 &lt;div class="entry-info"&gt;
                      &lt;div class="block"&gt;&lt;img src="bilder/tumme10/3.jpg" width="110" height="147"&gt;
                          &lt;span class="silver"&gt;Silver: K2 - Kristianstadsbladet&lt;/span&gt;
                      &lt;/div&gt;
                 &lt;/div&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
  </code></pre>
  
  <p>I use a scrapy with the following code:</p>
  
  <pre><code>start_urls = [
      "http://www.designpriset.se/vinnare.php?year=2010"
  ]
  
  rules = (
      Rule(LinkExtractor(allow = "http://www.designpriset.se/", restrict_xpaths=('//*[@class="html-winners"]')), callback='parse_item'),
  )
  
  def parse(self, response):
      for sel in response.xpath('//*[@class="entry-info"]'):
          item = ByrauItem()
          annons_list = sel.xpath('//span[@class="gold"]/text()|//span[@class="silver"]/text()').extract()
          byrau_list = sel.xpath('//div/text()').extract()
          kategori_list = sel.xpath('/preceding::h2/text()').extract()
          for x in range(0,len(annons_list)):
              item['Annonsrubrik'] = annons_list[x]
              item['Byrau'] = byrau_list[x]
              item['Kategori'] = kategori_list[x]
              yield item
  </code></pre>
  
  <p>annons_list and byrau_list works perfect, they use xpath to go down the heirarchy from the starting point <code>//*[@class="entry-info"]</code>. But kategori_list gives me "IndexError: list index out of range". Am I writing the xpath preceding axe the wrong way?</p>