title: How to get path of all elements in lxml with attribute
body: <p>I have the following code:</p>
  
  <pre><code>tree = etree.ElementTree(new_xml)
  for e in new_xml.iter():
      print tree.getpath(e), e.text
  </code></pre>
  
  <p>This will give me something like the following:</p>
  
  <pre><code>/Item/Purchases 
  
  /Item/Purchases/Purchase[1] 
  /Item/Purchases/Purchase[1]/URL http://tvgo.xfinity.com/watch/x/6091165185315991112/movies
  /Item/Purchases/Purchase[1]/Rating R
  
  /Item/Purchases/Purchase[2] 
  /Item/Purchases/Purchase[2]/URL http://tvgo.xfinity.com/watch/x/6091165185315991112/movies
  /Item/Purchases/Purchase[2]/Rating R
  </code></pre>
  
  <p>However, I need to get the path not of the list element but of the attribute. Here is what the xml looks like:</p>
  
  <pre><code>&lt;Item&gt;
    &lt;Purchases&gt;
       &lt;Purchase Country="US"&gt;
        &lt;URL&gt;http://tvgo.xfinity.com/watch/x/6091165US&lt;/URL&gt;
        &lt;Rating&gt;R&lt;/Rating&gt;
      &lt;/Purchase&gt;
       &lt;Purchase Country="CA"&gt;
        &lt;URL&gt;http://tvgo.xfinity.com/watch/x/6091165CA&lt;/URL&gt;
        &lt;Rating&gt;R&lt;/Rating&gt;
      &lt;/Purchase&gt;
  &lt;/Item&gt;
  </code></pre>
  
  <p>How would I get the following path instead?</p>
  
  <pre><code>/Item/Purchases 
  
  /Item/Purchases/Purchase[@Country="US"]
  /Item/Purchases/Purchase[@Country="US"]/URL http://tvgo.xfinity.com/watch/x/6091165185315991112/movies
  /Item/Purchases/Purchase[@Country="US"]/Rating R
  
  /Item/Purchases/Purchase[@Country="CA"]
  /Item/Purchases/Purchase[@Country="CA"]/URL http://tvgo.xfinity.com/watch/x/6091165185315991112/movies
  /Item/Purchases/Purchase[@Country="CA"]/Rating R
  </code></pre>