title: python lxml xpath AttributeError (NoneType) with correct xpath and usually working
body: <p>I am trying to migrate a forum to phpbb3 with python/xpath. Although I am pretty new to python and xpath, it is going well. However, I need help with an error.</p>
  
  <p>(The <a href="http://www.razyboard.com/system/morethread-alte-korken-fruchtweinkeller-89069-6046822-0.html" rel="nofollow">source file</a> has been downloaded and processed with tagsoup.)</p>
  
  <p>Firefox/Firebug show xpath: <code>/html/body/table[5]/tbody/tr[position()&gt;1]/td/a[3]/b</code></p>
  
  <p>(in my script without tbody)</p>
  
  <p>Here is an abbreviated version of my code:</p>
  
  <pre><code>forumfile="morethread-alte-korken-fruchtweinkeller-89069-6046822-0.html"
  XPOSTS = "/html/body/table[5]/tr[position()&gt;1]"
  t = etree.parse(forumfile)
  allposts = t.xpath(XPOSTS)
  
  XUSER = "td[1]/a[3]/b"
  XREG = "td/span"
  XTIME = "td[2]/table/tr/td[1]/span"
  XTEXT = "td[2]/p"
  XSIG = "td[2]/i"
  XAVAT = "td/img[last()]"
  
  XPOSTITEL = "/html/body/table[3]/tr/td/table/tr/td/div/h3"
  XSUBF = "/html/body/table[3]/tr/td/table/tr/td/div/strong[position()=1]"
  
  for p in allposts:
      unreg=0
      username = None
      username = p.find(XUSER).text          #this is where it goes haywire
  </code></pre>
  
  <p>When the loop hits user "tompson" / position()=11 at the end of the file, I get</p>
  
  <pre><code>AttributeError: 'NoneType' object has no attribute 'text'
  </code></pre>
  
  <p>I've tried a lot of <code>try except else finallys</code>, but they weren't helpful.</p>
  
  <p>I am getting much more information later in the script such as date of post, date of user registry, the url and attributes of the avatar, the content of the post...</p>
  
  <p>The script works for hundreds of other files/sites of this forum.</p>
  
  <p>This is no encode/decode problem. And it is not "limited" to the XUSER part. I tried to "hardcode" the username, then the date of registry will fail. If I skip those, the text of the post (code see below) will fail...</p>
  
  <pre><code>#text of getpost
  text = etree.tostring(p.find(XTEXT),pretty_print=True)
  </code></pre>
  
  <p>Now, this whole error would make sense if my xpath would be wrong. However, all the other files and the first numbers of users in this file work. it is only this "one" at position()=11</p>
  
  <p>Is position() uncapable of going >10 ? I don't think so?
  Am I missing something?</p>