title: copy xml node and children to new xml file
body: <p>I have the following code that loops over a set of records and moves each record to a new file: </p>
  
  <pre><code>import os
  import xml.etree.cElementTree as ET
  
  for filename in os.listdir('modemuze'):
      if filename.endswith('.xml'):
  
          original_tree = ET.ElementTree(file='modemuze/'+filename)
          root = original_tree.getroot()
  
          for child in root[2]:
              if child.tag == "{http://www.openarchives.org/OAI/2.0/}record":
                  new_tree = ET.ElementTree(file='test.xml')
                  new_root = new_tree.getroot()
                  new_root.append(child)
  </code></pre>
  
  <p>the file which contains the records i want to move has to following structure:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;responseDate&gt;2018-02-14T12:15:11.241+02:00&lt;/responseDate&gt;
      &lt;request verb="ListRecords"&gt;147.102.11.65:9000/fashionedmfp/oai&lt;/request&gt;
      &lt;ListRecords&gt;
          &lt;record&gt;
              &lt;header&gt;
                  &lt;identifier&gt;oai:fashionedmfp:8c549bcd078e2ce84a265d318547c5f8e8bf0cd0&lt;/identifier&gt;
                  &lt;datestamp&gt;2016-06-27&lt;/datestamp&gt;
              &lt;/header&gt;
              &lt;metadata&gt;
                  &lt;rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:edm="http://www.europeana.eu/schemas/edm/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:edmfp="http://www.europeanafashion.eu/edmfp/" xmlns:rdaGr2="http://rdvocab.info/ElementsGr2/" xmlns:ore="http://www.openarchives.org/ore/terms/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:mrel="http://id.loc.gov/vocabulary/relators/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:wgs84="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:crm="http://www.cidoc-crm.org/rdfs/cidoc_crm_v5.0.2_english_label.rdfs#" xmlns:gr="http://www.heppnetz.de/ontologies/goodrelations/v1#" xmlns:xalan="http://xml.apache.org/xalan" xmlns:skos="http://www.w3.org/2004/02/skos/core#"&gt;
                      &lt;edm:ProvidedCHO rdf:about="localID/europeana-fashion/10918x1y95563"&gt;
                          &lt;dcterms:created&gt;circa 1855-1874&lt;/dcterms:created&gt;
                          &lt;dcterms:issued&gt;1875&lt;/dcterms:issued&gt;
                          &lt;dcterms:issued&gt;1875&lt;/dcterms:issued&gt;
                          &lt;dcterms:medium&gt;katoen&lt;/dcterms:medium&gt;
                          &lt;dcterms:provenance&gt;schenking&lt;/dcterms:provenance&gt;
                          &lt;dcterms:provenance&gt;1958&lt;/dcterms:provenance&gt;
                          &lt;dcterms:spatial&gt;
                              &lt;edm:Place&gt;
                                  &lt;skos:prefLabel&gt;Nederland&lt;/skos:prefLabel&gt;
                              &lt;/edm:Place&gt;
                          &lt;/dcterms:spatial&gt;
                          &lt;dcterms:creator&gt;
                              &lt;edm:Agent/&gt;
                          &lt;/dcterms:creator&gt;
                          &lt;dc:creator&gt;
                              &lt;edm:Agent/&gt;
                          &lt;/dc:creator&gt;
                          &lt;dc:description&gt;Jurk (kind) van wit piqué, gegarneerd met broderie en soustache&lt;/dc:description&gt;
                          &lt;dc:identifier&gt;0061211&lt;/dc:identifier&gt;
                          &lt;dc:title&gt;jurken&lt;/dc:title&gt;
                          &lt;dc:title&gt;kinderkleding&lt;/dc:title&gt;
                          &lt;edm:type&gt;IMAGE&lt;/edm:type&gt;
                          &lt;edmfp:localType&gt;jurken&lt;/edmfp:localType&gt;
                          &lt;edmfp:localType&gt;kinderkleding&lt;/edmfp:localType&gt;
                          &lt;edmfp:technique&gt;piqué-weefsel&lt;/edmfp:technique&gt;
                      &lt;/edm:ProvidedCHO&gt;
                      &lt;ore:Aggregation rdf:about="localID/europeana-fashion/Aggregation_10918x1y95563"&gt;
                          &lt;edm:aggregatedCHO rdf:resource="localID/europeana-fashion/10918x1y95563"/&gt;
                          &lt;edm:dataProvider&gt;
                              &lt;edm:Agent&gt;
                                  &lt;skos:prefLabel&gt;Gemeentemuseum Den Haag&lt;/skos:prefLabel&gt;
                              &lt;/edm:Agent&gt;
                          &lt;/edm:dataProvider&gt;
                          &lt;edm:hasView&gt;
                              &lt;edm:WebResource rdf:about="http://images.gemeentemuseum.nl/br/0061211.jpg"/&gt;
                          &lt;/edm:hasView&gt;
                          &lt;edm:isShownBy&gt;
                              &lt;edm:WebResource rdf:about="http://images.gemeentemuseum.nl/br/0061211.jpg"/&gt;
                          &lt;/edm:isShownBy&gt;
                          &lt;edm:provider&gt;
                              &lt;edm:Agent rdf:about="http://www.europeanafashion.eu/"&gt;
                                  &lt;skos:prefLabel&gt;Europeana Fashion&lt;/skos:prefLabel&gt;
                              &lt;/edm:Agent&gt;
                          &lt;/edm:provider&gt;
                          &lt;edm:rights rdf:resource="http://www.europeana.eu/rights/rr-f/"/&gt;
                      &lt;/ore:Aggregation&gt;
                  &lt;/rdf:RDF&gt;
              &lt;/metadata&gt;
          &lt;/record&gt;
      &lt;/ListRecords&gt;
  &lt;/OAI-PMH&gt;
  </code></pre>
  
  <p>and the file i want to place the records in has the following structure: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;ListRecords&gt;
  &lt;/ListRecords&gt;
  </code></pre>
  
  <p>but when i run this code my test.xml file contains no records..<br>
  Why is this happening?<br>
  I am totally new to XML and python so if i missed something or something is unclear please let me know so i can clarify or add it.<br>
  I am doing this is python 2.7<br>
  All help and suggestions are very much appreciated! </p>