title: create XML file using minidom
body: <p>I supposed to create a xml file using python in the below format ,</p>
  <pre><code>&lt;datasource formatted-name='federated' inline='true'&gt;
    &lt;connection class='federated'&gt;
      &lt;named-connections&gt;
        &lt;named-connection caption='Sample - Superstore' name='excel.1ew9u4t0tggb9315darmm0nfz2kb'&gt;
          &lt;connection class='excel' driver='' header='yes' imex='1' password='' server='' /&gt;
        &lt;/named-connection&gt;
      &lt;/named-connections&gt;
    &lt;/connection&gt;
  &lt;/datasource&gt;
  </code></pre>
  <p>i tried with minidom</p>
  <pre class="lang-py prettyprint-override"><code>from xml.dom import minidom 
  import os  
  
  root = minidom.Document() 
    
  xml = root.createElement('Datasource')  
  root.appendChild(xml) 
    
  productChild = root.createElement('Connection') 
  productChild.setAttribute('name', 'Federated') 
  xml.appendChild(productChild) 
  
  productChild1 = root.createTextNode('named-connections') 
  productChild2=root.createElement('named-connection')
  productChild2.setAttribute('name', 'caption=SampleSuperstore')
  xml.appendChild(productChild1)
    
  xml_str = root.toprettyxml(indent =&quot;\t&quot;)  
    
  save_path_file = &quot;gfg.xml&quot;
    
  with open(save_path_file, &quot;w&quot;) as f: 
      f.write(xml_str)
  
  </code></pre>
  <p>I'm getting only this</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; ?&gt;
  &lt;Database&gt;
      &lt;Connection name=&quot;Federated&quot;/&gt;
      named-connections
  &lt;/Database&gt;
  </code></pre>
  <p>i don't know how to create a child node inside <code>&lt;named-connections&gt;</code>. Can someone help??</p>
  <p>Thanks,
  Aarush</p>