title: LXML Xpath does not seem to return full path
body: <p>OK I'll be the first to admit its is, just not the path I want and I don't know how to get it.</p>
  
  <p>I'm using Python 3.3 in Eclipse with Pydev plugin in both Windows 7 at work and ubuntu 13.04 at home. I'm new to python and have limited programming experience.</p>
  
  <p>I'm trying to write a script to take in an XML Lloyds market insurance message, find all the tags and dump them in a .csv where we can easily update them and then reimport them to create an updated xml.</p>
  
  <p>I have managed to do all of that except when I get all the tags it only gives the tag name and not the tags above it. </p>
  
  <pre><code>&lt;TechAccount Sender="broker" Receiver="insurer"&gt;
  &lt;UUId&gt;2EF40080-F618-4FF7-833C-A34EA6A57B73&lt;/UUId&gt;
  &lt;BrokerReference&gt;HOY123/456&lt;/BrokerReference&gt;
  &lt;ServiceProviderReference&gt;2012080921401A1&lt;/ServiceProviderReference&gt;
  &lt;CreationDate&gt;2012-08-10&lt;/CreationDate&gt;
  &lt;AccountTransactionType&gt;premium&lt;/AccountTransactionType&gt;
  &lt;GroupReference&gt;2012080921401A1&lt;/GroupReference&gt;
  &lt;ItemsInGroupTotal&gt;
  &lt;Count&gt;1&lt;/Count&gt;
  &lt;/ItemsInGroupTotal&gt;
  &lt;ServiceProviderGroupReference&gt;8-2012-08-10&lt;/ServiceProviderGroupReference&gt;
  &lt;ServiceProviderGroupItemsTotal&gt;
  &lt;Count&gt;13&lt;/Count&gt;
  &lt;/ServiceProviderGroupItemsTotal&gt;
  </code></pre>
  
  <p>That is a fragment of the XML. What I want is to find all the tags and their path. For example for  I want to show it as ItemsInGroupTotal/Count but can only get it as Count.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>xml = etree.parse(fullpath)
  print( xml.xpath('.//*'))
  all_xpath = xml.xpath('.//*')
  every_tag = []
  for i in all_xpath:
      single_tag = '%s,%s' % (i.tag, i.text)
      every_tag.append(single_tag)
  print(every_tag)
  </code></pre>
  
  <p>This gives:</p>
  
  <pre><code>'{http://www.ACORD.org/standards/Jv-Ins-Reinsurance/1}ServiceProviderGroupReference,8-2012-08-10', '{http://www.ACORD.org/standards/Jv-Ins-Reinsurance/1}ServiceProviderGroupItemsTotal,\n', '{http://www.ACORD.org/standards/Jv-Ins-Reinsurance/1}Count,13',
  </code></pre>
  
  <p>As you can see Count is shown as {namespace}Count, 13 and not {namespace}ItemsInGroupTotal/Count, 13</p>
  
  <p>Can anyone point me towards what I need?</p>
  
  <p>Thanks (hope my first post is OK)</p>
  
  <p>Adam</p>
  
  <p>EDIT:</p>
  
  <p>This is my code now:
      with open(fullpath, 'rb') as xmlFilepath:
         xmlfile = xmlFilepath.read()</p>
  
  <pre><code>fulltext = '%s' % xmlfile
  text = fulltext[2:]
  print(text)
  
  
  xml = etree.fromstring(fulltext)
  tree = etree.ElementTree(xml)
  
  every_tag = ['%s, %s' % (tree.getpath(e), e.text) for e in xml.iter()]
  print(every_tag)
  </code></pre>
  
  <p>But this returns an error:
  ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.</p>
  
  <p>I remove the first two chars as thy are b' and it complained it didn't start with a tag</p>
  
  <p>Update:</p>
  
  <p>I have been playing around with this and if I remove the xis: xxx tags and the namespace stuff at the top it works as expected. I need to keep the xis tags and be able to identify them as xis tags so can't just delete them.</p>
  
  <p>Any help on how I can achieve this?</p>