title: ElementTree insert element from another file and save
body: <p>File1.xml</p>
  
  <pre><code>   &lt;!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'&gt;
      &lt;qgis projectname="" version="2.6.1-Brighton"&gt;
          &lt;title&gt;&lt;/title&gt;
           &lt;mapcanvas&gt;
  
          &lt;/mapcanvas&gt;
        &lt;/qgis&gt;
  </code></pre>
  
  <p>File2.xml</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;legend updateDrawingOrder="true"&gt;
      &lt;legendlayer checked="Qt::Checked" name="Grid1.shp" open="true" showFeatureCount="0"&gt;
          &lt;filegroup hidden="false" open="true"&gt;
              &lt;legendlayerfile isInOverview="0" layerid="Grid1_shp20150117231830763" visible="1"/&gt;
          &lt;/filegroup&gt;
      &lt;/legendlayer&gt;
      &lt;legendlayer checked="Qt::Checked" name="world_countries.shp" open="true" showFeatureCount="0"&gt;
          &lt;filegroup hidden="false" open="true"&gt;
              &lt;legendlayerfile isInOverview="0" layerid="world_countries_shp20150117231830790" visible="1"/&gt;
          &lt;/filegroup&gt;
      &lt;/legendlayer&gt;
  &lt;/legend&gt;
  </code></pre>
  
  <p>I need to a section of File1.XML to File2.XML...Below script printing the desired but only for element.How can this update be saved in File2.XML?</p>
  
  <pre><code>from xml.etree import ElementTree as et
  
  tree1 = xml.etree.ElementTree.parse('File1.xml')
  root1 = tree1.getroot()
  
  tree2 = xml.etree.ElementTree.parse('File2.xml')
  root2 = tree2.getroot()
  
  root2.insert(0,root1)
  print et.tostring(root2)
  </code></pre>
  
  <p>The target software expects the tags in below format</p>
  
  <pre><code>&lt;!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'&gt;
      &lt;qgis projectname="" version="2.6.1-Brighton"&gt;
          &lt;title&gt;&lt;/title&gt;
  &lt;legend updateDrawingOrder="true"&gt;
      &lt;legendlayer checked="Qt::Checked" name="Grid1.shp" open="true" showFeatureCount="0"&gt;
          &lt;filegroup hidden="false" open="true"&gt;
              &lt;legendlayerfile isInOverview="0" layerid="Grid1_shp20150117231830763" visible="1"/&gt;
          &lt;/filegroup&gt;
      &lt;/legendlayer&gt;
      &lt;legendlayer checked="Qt::Checked" name="world_countries.shp" open="true" showFeatureCount="0"&gt;
          &lt;filegroup hidden="false" open="true"&gt;
              &lt;legendlayerfile isInOverview="0" layerid="world_countries_shp20150117231830790" visible="1"/&gt;
          &lt;/filegroup&gt;
      &lt;/legendlayer&gt;
  &lt;/legend&gt;
  
           &lt;mapcanvas&gt;
  
          &lt;/mapcanvas&gt;
        &lt;/qgis&gt;
  </code></pre>