title: Pretty print subnode without namespace declaration
body: <p>I have an xml document and I want to extract a subnode (boundedBy) and pretty_print it exactly as it looks in the original document (with exception to the pretty formatting).</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;wfs:FeatureCollection
     xmlns:sei="https://somedomain.com/namespace"
     xmlns:wfs="http://www.opengis.net/wfs"
     xmlns:gml="http://www.opengis.net/gml"
     xmlns:ogc="http://www.opengis.net/ogc"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd 
                         https://somedomain.com/schemas/wfsnamespace some.xsd"&gt;
        &lt;gml:boundedBy&gt;
          &lt;gml:Box srsName="EPSG:4326"&gt;
              &lt;gml:coordinates&gt;-10.934396,-139.997120 77.396455,-53.627763&lt;/gml:coordinates&gt;
          &lt;/gml:Box&gt;
        &lt;/gml:boundedBy&gt;
      &lt;gml:featureMember&gt;
        &lt;sei:HUB_HEIGHT_FCST&gt;
          &lt;!--- This is the section I want ---&gt;
          &lt;gml:boundedBy&gt;
              &lt;gml:Box srsName="EPSG:4326"&gt;
                  &lt;gml:coordinates&gt;14.574435,-139.997120 14.574435,-139.997120&lt;/gml:coordinates&gt;
              &lt;/gml:Box&gt;
          &lt;/gml:boundedBy&gt;
          &lt;!--- This is the section I want ---&gt;
          &lt;sei:geometry_4326&gt;
          &lt;gml:Point srsName="EPSG:4326"&gt;
            &lt;gml:coordinates&gt;14.574435,-139.997120&lt;/gml:coordinates&gt;
          &lt;/gml:Point&gt;
          &lt;/sei:geometry_4326&gt;
          &lt;sei:rundatetime&gt;2017-09-26 00:00:00&lt;/sei:rundatetime&gt;
          &lt;sei:validdatetime&gt;2017-09-26 17:00:00&lt;/sei:validdatetime&gt;
        &lt;/sei:HUB_HEIGHT_FCST&gt;
      &lt;/gml:featureMember&gt;
  &lt;/wfs:FeatureCollection&gt;
  </code></pre>
  
  <p>Here is how I'm extracting the subnode:</p>
  
  <pre class="lang-python prettyprint-override"><code># parse the xml string
  parser = etree.XMLParser(remove_blank_text=True, remove_comments=True, recover=False, strip_cdata=False)
  root = etree.fromstring(xmlstr, parser=parser)
  #find the subnode I want 
  subnodes = root.xpath("./gml:boundedBy", namespaces={'gml': 'http://www.opengis.net/gml'})
  subnode = subnodes[0]
  # make a pretty output
  xmlstr = etree.tostring(subnode, xml_declaration=False, encoding="UTF-8", pretty_print=True)
  print xmlstr
  </code></pre>
  
  <p>Which gives me this. Unfortunately lxml is adding the namespaces to the boundedBy node (which makes sense for the sake of completeness in xml). 
  </p>
  
  <pre><code>&lt;gml:boundedBy xmlns:gml="http://www.opengis.net/gml" xmlns:sei="https://somedomain.com/namespace" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    &lt;gml:Box srsName="EPSG:4326"&gt;
      &lt;gml:coordinates&gt;-10.934396,-139.997120 77.396455,-53.627763&lt;/gml:coordinates&gt;
    &lt;/gml:Box&gt;
  &lt;/gml:boundedBy&gt;
  </code></pre>
  
  <p><strong>I only want the subnode as it looked in the original document.</strong>  </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;gml:boundedBy&gt;
      &lt;gml:Box srsName="EPSG:4326"&gt;
          &lt;gml:coordinates&gt;14.574435,-139.997120 14.574435,-139.997120&lt;/gml:coordinates&gt;
      &lt;/gml:Box&gt;
  &lt;/gml:boundedBy&gt;
  </code></pre>
  
  <p>I'm flexible with not using lxml, but either way I haven't found options on how to accomplish this.</p>
  
  <hr>
  
  <p>edit:
  Since it was pointed out that I should explain why I want to do this...</p>
  
  <p>I'm trying to log the xml fragment without altering it's original structure. The automated test I'm building looks at certain nodes for correctness. In the process I'm logging the fragment and want to make it a bit more readable for the person reviewing.  Some of the fragments can get fairly large which is why pretty_print is so nice.  </p>