title: How to convert an XML to junit XML?
body: <p>A python script is run in jenkins and saves the test results as html and xml files. 
  How do I convert this xml file to <strong>JUNIT understandable XML file</strong>? 
  <a href="https://github.com/TheGoldenHorn/Example-XML/blob/master/finalResult_172.217.163.100_443.xml" rel="nofollow noreferrer">Example XML File on github</a></p>
  
  <p><em>This is the funnction I am using to convert the pandas dataframe to XML:</em></p>
  
  <pre><code>def to_xml(df, filename=None, mode='w'):
      def row_to_xml(row):
          xml = ['&lt;testsuite&gt;']
          for i, col_name in enumerate(row.index):
              xml.append('  &lt;testcase class="{0}"&gt;{1}&lt;/testcase&gt;'.format(col_name, row.iloc[i]))
          xml.append('&lt;/testsuite&gt;')
          return '\n'.join(xml)
      res = '\n'.join(df.apply(row_to_xml, axis=1))
  
      if filename is None:
          return (f"&lt;testsuites&gt;\n{res.replace('&lt;=','&amp;gt;')}\n&lt;/testsuites&gt;")
      with open(filename, mode) as f:
          f.write((f"&lt;testsuites&gt;\n{res.replace('&lt;=','&amp;gt;')}\n&lt;/testsuites&gt;"))
  </code></pre>