title: Python lxml: how to get human-readable XPath for XML element?
body: <p>I have a short XML document:</p>
  
  <pre><code>&lt;tag1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns="http://example.com/2009/namespace"&gt;
      &lt;tag2&gt;
          &lt;tag3/&gt;
          &lt;tag3/&gt;
      &lt;/tag2&gt;
  &lt;/tag1&gt;
  </code></pre>
  
  <p>A short Python program loads this XML file like this:</p>
  
  <pre><code>from lxml import etree
  
  f = open( 'myxml.xml' )
  tree = etree.parse(f)
  MY_NAMESPACE = 'http://example.com/2009/namespace'
  xpath = etree.XPath( '/f:tag1/f:tag2/f:tag3', namespaces = { 'f': MY_NAMESPACE } )
  # get first element that matches xpath
  elem = xpath(tree)[0]
  # get xpath for an element 
  print tree.getpath(elem)
  </code></pre>
  
  <p>I am expecting to get a meaningful, human-readable xpath with this code, however, instead I get a string like <code>/*/*/*[1]</code>.</p>
  
  <p>Any idea what could be causing this and how I can diagnose this issue?</p>
  
  <p>Note: Using Python 2.7.9 and lxml 2.3</p>