title: Exporting XML header and doctype to XML file
body: <p>I want to use a java script for my bachelor thesis that uses XML files as input. Since most of my other work was done in python, i want to create a bridge between the two programs by opening the XML file in python and changing some class attribute values to previously calculated results from my python code. Then i want to write the XML file in python so the java script can use it as input. I have not had any issues editing the values using xml.etree.ElementTree but after writing the file the values are changed but the header and DOCType are completly gone. Is there any way to add or just not remove them in the first place using python? I have searched the internet but have not been able to find a good solution yet. I am pretty new to XMLs and Java unfortunately.</p>
  <p>Im posting here for the first time, so im sorry if i forgot any necessary information</p>
  <p>This is my XML:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!DOCTYPE uam SYSTEM &quot;src/main/resources/dtd/uam.dtd&quot;&gt;
  
  &lt;uam&gt;
      &lt;stations&gt;
          &lt;station id=&quot;MUC_OD_2_1&quot; name=&quot;Location 948&quot; preflighttime=&quot;0&quot; postflighttime=&quot;0&quot; defaultwaittime=&quot;0&quot; link=&quot;uam_sl-uam_st_MUC_OD_2_1_ga-uam_st_MUC_OD_2_1_fa&quot; /&gt;
          &lt;station id=&quot;MUC_OD_2_2&quot; name=&quot;Location 1000&quot; preflighttime=&quot;0&quot; postflighttime=&quot;0&quot; defaultwaittime=&quot;0&quot; link=&quot;uam_sl-uam_st_MUC_OD_2_2_ga-uam_st_MUC_OD_2_2_fa&quot; /&gt;
      &lt;/stations&gt;
      &lt;vehicleTypes&gt;
          &lt;vehicleType id=&quot;MC&quot; range=&quot;99999&quot; capacity=&quot;6&quot; cruisespeed=&quot;60.0&quot; verticalspeed=&quot;10.0&quot; boardingtime=&quot;0&quot; deboardingtime=&quot;0&quot; turnaroundtime=&quot;0&quot; /&gt;
      &lt;/vehicleTypes&gt;
      &lt;vehicles&gt;
          &lt;vehicle id=&quot;uam_vh_MUC_OD_2_1-0&quot; type=&quot;MC&quot; initialstation=&quot;MUC_OD_2_1&quot; starttime=&quot;00:00:00&quot; endtime=&quot;30:00:00&quot; /&gt;
          &lt;vehicle id=&quot;uam_vh_MUC_OD_2_2-0&quot; type=&quot;MC&quot; initialstation=&quot;MUC_OD_2_2&quot; starttime=&quot;00:00:00&quot; endtime=&quot;30:00:00&quot; /&gt;
      &lt;/vehicles&gt;
  &lt;/uam&gt;
  </code></pre>
  <p>This is my Python code:</p>
  <pre class="lang-py prettyprint-override"><code>import xml.etree.ElementTree as ET
  from dictionary import getDict
  from Dict_manufacturers import getDict_manu
  
  def VehiclesInput(UAMtype):
      tree = ET.parse('muc_network_s_od_2_v_uam_vehicles.xml')
      root = tree.getroot()
      
      if ...(editing values) 
          
              
      tree.write('muc_network_s_od_2_v_uam_vehicles.xml', encoding = &quot;UTF-8&quot;, xml_declaration = True)
      
      return
  </code></pre>