title: python parse XML with lxml giving the right parser parameters
body: <p>I am parsing xml data with lxml in python</p>
  <p>The data looks like this:</p>
  <pre><code>string='''&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;/n
      &lt;div type=&quot;request&quot; xml:base=&quot;/k-api/7728&quot; xml:lang=&quot;en&quot; &gt;
      &lt;div n=&quot;&quot; type=&quot;request&quot; xml:id=&quot;_54f59d0003&quot;&gt;
          &lt;p xml:id=&quot;_54f59d0004&quot;/&gt;
          &lt;p xml:id=&quot;_54f59d0005&quot;&gt;Requests &lt;/p&gt;
      &lt;/div&gt;
      &lt;div n=&quot;0001&quot; type=&quot;request&quot; xml:id=&quot;_54f59d0006&quot;&gt;
          &lt;p xml:id=&quot;_54f59d0007&quot;&gt;1.  First request.
          &lt;/p&gt;
      &lt;/div&gt;
      &lt;div n=&quot;0002&quot; type=&quot;claim&quot; xml:id=&quot;_54f59d0008&quot;&gt;
           &lt;p xml:id=&quot;_54f59d0009&quot;&gt;2. Second request.
           &lt;/p&gt;
      &lt;/div&gt;
      &lt;div n=&quot;0003&quot; type=&quot;request&quot; xml:id=&quot;_54f59d0010&quot;&gt;
           &lt;p xml:id=&quot;_54f59d0011&quot;&gt;3. Thrid requests.
           &lt;/p&gt;
      &lt;/div&gt;
      &lt;div n=&quot;0004&quot; type=&quot;request&quot; xml:id=&quot;_54f59d0012&quot;&gt;
          &lt;p xml:id=&quot;_54f59d0013&quot;&gt;4. request.
          &lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;'''
  
  
  import xml.etree.ElementTree as ET
  from lxml import etree
  parser = etree.XMLParser(encoding=&quot;UTF-8&quot;, resolve_entities=False, strip_cdata=False, recover=True, ns_clean=True)
  XML_tree = etree.fromstring(xml_string,parser=parser)
  </code></pre>
  <p>This does not work because several reasons
  a) the line break \n: I can solve that by</p>
  <pre><code>xml_string = ''.join(string.splitlines())
  </code></pre>
  <p>but I am wondering if there is a way to tell in the parser that lxml should not take care of line breaks
  b) Utf-8 first line in the string. I can also take care of it by:</p>
  <pre><code>xml_string = xml_string.replace('&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;','')
  </code></pre>
  <p>before parsing, but is there a way to do it all inside the lxml parser?, i.e telling the parser to remove line breaks and to forget about the encoding (note: encoding=&quot;UTF-8&quot; or encoding=None will not solve the problem)</p>
  <p>Thanks</p>
  <p>EDIT 1: The rror that I get when not removing the encoding bit is:
  ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.</p>