title: Python lxml / XPathEvalError : Invalid expression when I parse xml file
body: <p>I try to parse an XML file with lxml. It works with some files but the last one gave me an error:</p>
  
  <pre><code>XPathEvalError at /admin/xml_exportation/xml/add/
  Invalid expression
  </code></pre>
  
  <p>Here is the xml code :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;export source="Source" version="1.0" date="2014-02-21T17:46:57"&gt;
    &lt;Agence ID="XX1" externRef="XX1" customCode="38495"&gt;
      &lt;Biens&gt;
        &lt;Bien ID="XX1-176" ref="XX1-176"&gt;
          &lt;DateMAJ&gt;2013-06-14T12:12:07&lt;/DateMAJ&gt;
        &lt;/Bien&gt;
      &lt;/Biens&gt;
    &lt;/Agence&gt;
  &lt;/export&gt;
  </code></pre>
  
  <p>And then the python code :</p>
  
  <pre><code>tree = etree.parse(xml_file) 
  root_path = '/export/Agence/Biens/Bien/'
  for element in tree.xpath(root_path): 
     print(element)
  </code></pre>
  
  <p>I tried to change the path but it gave me the same error.</p>
  
  <p>Thank you for your help.</p>
  
  <h1><strong>EDIT</strong></h1>
  
  <pre><code>Internal Server Error: /admin/xml_exportation/xml/add/
  Traceback (most recent call last):
    File "/home/python-envs/website.com/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
      response = callback(request, *callback_args, **callback_kwargs)
    File "/home/python-envs/website.com/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 372, in wrapper
      return self.admin_site.admin_view(view)(*args, **kwargs)
    File "/home/python-envs/website.com/local/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
      response = view_func(request, *args, **kwargs)
    File "/home/python-envs/website.com/local/lib/python2.7/site-packages/django/views/decorators/cache.py", line 89, in _wrapped_view_func
      response = view_func(request, *args, **kwargs)
    File "/home/python-envs/website.com/local/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 202, in inner
      return view(request, *args, **kwargs)
    File "/home/python-envs/website.com/local/lib/python2.7/site-packages/django/utils/decorators.py", line 25, in _wrapper
      return bound_func(*args, **kwargs)
    File "/home/python-envs/website.com/local/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
      response = view_func(request, *args, **kwargs)
    File "/home/python-envs/website.com/local/lib/python2.7/site-packages/django/utils/decorators.py", line 21, in bound_func
      return func(self, *args2, **kwargs2)
    File "/home/python-envs/website.com/local/lib/python2.7/site-packages/django/db/transaction.py", line 223, in inner
      return func(*args, **kwargs)
    File "/home/python-envs/website.com/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1007, in add_view
      self.save_model(request, new_object, form, False)
    File "/home/python-envs/website.com/local/lib/python2.7/site-packages/django/contrib/admin/options.py", line 740, in save_model
      obj.save()
    File "astucesexperts/apps/xml_exportation/models.py", line 154, in save
      for element in tree.xpath(root_path): # Find each new property
    File "lxml.etree.pyx", line 2115, in lxml.etree._ElementTree.xpath (src/lxml/lxml.etree.c:57669)
    File "xpath.pxi", line 370, in lxml.etree.XPathDocumentEvaluator.__call__ (src/lxml/lxml.etree.c:146579)
    File "xpath.pxi", line 238, in lxml.etree._XPathEvaluatorBase._handle_result (src/lxml/lxml.etree.c:144977)
    File "xpath.pxi", line 224, in lxml.etree._XPathEvaluatorBase._raise_eval_error (src/lxml/lxml.etree.c:144832)
  XPathEvalError: Invalid expression
  </code></pre>
  
  <p>I also add the code from an xml file I could export with the script (changing the root path).</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;ANNONCES&gt;
      &lt;ANNONCE&gt;
          &lt;AGENCE_REF&gt;&lt;![CDATA[22]]&gt;&lt;/AGENCE_REF&gt;
          &lt;AGENCE_NOM&gt;&lt;![CDATA[Agence]]&gt;&lt;/AGENCE_NOM&gt;
  &lt;REFERENCE&gt;&lt;![CDATA[100lm]]&gt;&lt;/REFERENCE&gt;
          &lt;TRANSACTION&gt;&lt;![CDATA[2]]&gt;&lt;/TRANSACTION&gt;
          &lt;TYPE&gt;&lt;![CDATA[2]]&gt;&lt;/TYPE&gt;
          &lt;SOUSTYPE&gt;&lt;![CDATA[45]]&gt;&lt;/SOUSTYPE&gt;
          &lt;SURFACE&gt;&lt;![CDATA[100]]&gt;&lt;/SURFACE&gt;
      &lt;ANNONCE&gt;
  &lt;/ANNONCES&gt; 
  </code></pre>