title: Python Parsing nested XML and flattening the data
body: <p>I am trying to flatten the following XML data into CSV type table data.</p>
  
  <p>I could get the data in the Sal element and its attributes but I couldn't flatten SalC data to the parent sailing attributes to generate a flat table data.</p>
  
  <p>I want to flatten below XML data as so that I can write to database for some further processing.</p>
  
  <p>col1, col2, col3, col4, col5, col6, col6, col7, col8, col9, col10</p>
  
  <p>XML Data:</p>
  
  <pre><code>&lt;Sal col1="a1" col2="C" col3="12/5/2012" col4="a" col5="8" col6="True"&gt;
      &lt;SalC col7="A" col8="1" col9="2" col10="True"/&gt;
      &lt;SalC col7="A1" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="B" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="C" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="D" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="E" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="E1" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="F" col8="1" col9="2" col10="False"/&gt;
  &lt;/Sal&gt;
  &lt;Sal col1="a1" col2="C" col3="12/9/2012" col4="b" col5="8" col6="True"&gt;
      &lt;SalC col7="A" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="B" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="C" col8="1" col9="2" col10="True"/&gt;
      &lt;SalC col7="D" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="E" col8="1" col9="2" col10="False"/&gt;
  &lt;/Sal&gt;
  &lt;Sal col1="a2" col2="C" col3="12/8/2012" col4="c" col5="15" col6="True"&gt;
      &lt;SalC col7="A" col8="1" col9="2" col10="True"/&gt;
      &lt;SalC col7="A1" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="B" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="C" col8="1" col9="2" col10="True"/&gt;
      &lt;SalC col7="D" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="E" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="E1" col8="1" col9="2" col10="True"/&gt;
      &lt;SalC col7="F" col8="1" col9="2" col10="False"/&gt;
  &lt;/Sal&gt;
  &lt;Sal col1="a3" col2="C" col3="12/9/2012" col4="d" col5="8" col6="True"&gt;
      &lt;SalC col7="A" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="B" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="C" col8="1" col9="2" col10="False"/&gt;
      &lt;SalC col7="D" col8="1" col9="2" col10="True"/&gt;
      &lt;SalC col7="E" col8="1" col9="2" col10="False"/&gt;
  &lt;/Sal&gt;
  </code></pre>
  
  <p>Thank you for your help.</p>