title: Format string to XML file
body: <p>I want to reformat a string to the XML structure, but my string is not on an XML format (using Python 2.7).
  I believe the correct way is to first create an XML format of the input in one line and then use XML Pretty Print for making it an XML file with multi rows and indentation (
  <a href="https://stackoverflow.com/questions/749796/pretty-printing-xml-in-python">Pretty printing XML in Python</a>).</p>
  <p>Below there is an example of an input after a History Server REST API's call to Hadoop server <a href="https://hadoop.apache.org/docs/r2.4.1/hadoop-yarn/hadoop-yarn-site/HistoryServerRest.html" rel="nofollow noreferrer">1</a>.
  Input:</p>
  <pre><code>'{&quot;jobAttempts&quot;:{&quot;jobAttempt&quot;:[{&quot;nodeHttpAddress&quot;:&quot;slave2:8042&quot;,&quot;nodeId&quot;:&quot;slave2:39637&quot;,&quot;id&quot;:1,&quot;startTime&quot;:1544691730439,&quot;containerId&quot;:&quot;container_1544631848492_0013_01_000001&quot;,&quot;logsLink&quot;:&quot;http://23.22.43.90:19888/jobhistory/logs/slave2:39637/container_1544631848492_0013_01_000001/job_1544631848492_0013/hadoop2&quot;}]}}' 
  </code></pre>
  <p>Output:</p>
  <pre><code>'&lt;jobAttempts&gt;&lt;jobAttempt&gt;&lt;nodeHttpAddress&gt;slave2:8042&lt;/nodeHttpAddress&gt;&lt;nodeId&gt;slave2:39637&lt;/nodeId&gt;&lt;id&gt;1&lt;/id&gt;&lt;startTime&gt;1544691730439&lt;/startTime&gt;&lt;containerId&gt;container_1544631848492_0013_01_000001&lt;/containerId&gt;&lt;logsLink&gt;http://23.22.43.90:19888/jobhistory/logs/slave2:39637/container_1544631848492_0013_01_000001/job_1544631848492_0013/hadoop2&lt;/logsLink&gt;&lt;/jobAttempt&gt;&lt;/jobAttempts&gt;' 
  </code></pre>
  <p>Final Output</p>
  <pre><code>&lt;jobAttempts&gt;
      &lt;jobAttempt&gt;
          &lt;nodeHttpAddress&gt;slave2:8042&lt;/nodeHttpAddress&gt;
          &lt;nodeId&gt;slave2:39637&lt;/nodeId&gt;
          &lt;id&gt;1&lt;/id&gt;
          &lt;startTime&gt;1544691730439&lt;/startTime&gt;
          &lt;containerId&gt;container_1544631848492_0013_01_000001&lt;/containerId&gt;
      &lt;logsLink&gt;http://23.22.43.90:19888/jobhistory/logs/slave2:39637/container_1544631848492_0013_01_000001/job_1544631848492_0013/hadoop2&lt;/logsLink&gt;
      &lt;/jobAttempts&gt;
  &lt;/jobAttempt&gt;
  </code></pre>
  <p>*This string is actually an XML file which does not appear to have any style information associated with it.</p>