title: How to parse XML containing prefixes but no namespace declarations with lxml?
body: <p>I have a bunch of XML files which are using prefixes but without the corresponding namespace declaration.</p>
  
  <p>Stuff like:</p>
  
  <pre><code>&lt;tal:block tal:condition="foo"&gt;
  ...
  &lt;/tal:block&gt;
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>&lt;div i18n:domain="my-app"&gt;
  ...
  </code></pre>
  
  <p>I know where those prefixes come from, an I tried the following, but without success:</p>
  
  <pre><code>from lxml import etree as ElementTree
  
  ElementTree.register_namespace("i18n", "http://namespaces.zope.org")
  ElementTree.register_namespace("tal", "http://xml.zope.org/namespaces/tal")
  
  with open(path) as fp:
      tree = ElementTree.parse(fp)
  </code></pre>
  
  <p>but lxml still chokes with:</p>
  
  <pre><code>lxml.etree.XMLSyntaxError: Namespace prefix i18n for domain on div is not defined, line 4, column 20
  </code></pre>
  
  <p>I know I can use <code>ElementTree.XMLParser(recover=True)</code>, but I would like to keep the prefix anyway, which this method don't.</p>
  
  <p>Any idea?</p>