title: Using XPath Following to get element from XML
body: <p>I have an XML like the following</p>
  
  <pre><code>&lt;li class="expandSubItem"&gt;
      &lt;span class="expandSubLink"&gt;Popular Neighborhoods&lt;/span&gt;
      &lt;ul class="secondSubNav" style="top:-0.125em;"&gt;
          &lt;li class="subItem"&gt;
              &lt;a class="subLink" href="/Hotels-g187147-zfn7236765-Paris_Ile_de_France-Hotels.html"&gt;Quartier Latin Hotels&lt;/a&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li class="expandSubItem"&gt;
      &lt;span class="expandSubLink"&gt;Popular Paris Categories&lt;/span&gt;
      &lt;ul class="secondSubNav" style="top:-0.125em;"&gt;
          &lt;li class="subItem"&gt;
              &lt;a class="subLink" href="/HotelsList-Paris-Cheap-Hotels-zfp10420.html"&gt;Paris Cheap Hotels&lt;/a&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>I want to get all links under "Popular Paris Categories". I used something like this <code>//li//a/@href/following::span[text()='Popular Singapore Categories']</code>, but it gave no results. Any idea how to get the correct result? Here is the snippet of the python code that I wrote.</p>
  
  <pre><code>t_url = 'https://www.tripadvisor.com/Tourism-g187147-Paris_Ile_de_France-Vacations.html'
  page = requests.get(t_url, timeout=30)
  tree = html.fromstring(page.content)
  
  links = tree.xpath('//li[span="Popular Paris Categories"]//a/@href')
  print links
  </code></pre>