title: Parsing the nested XML fields from PySpark Dataframe using UDF
body: <p>I have a scenario where I have XML data in a dataframe column.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">sex</th>
  <th style="text-align: center;">updated_at</th>
  <th style="text-align: right;">visitors</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">F</td>
  <td style="text-align: center;">1574264158</td>
  <td style="text-align: right;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I want to parse - Visitors column - the nested XML fields into columns in Dataframe using UDF</p>
  <p>Format of XML</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;visitors&gt; &lt;visitor id=&quot;9615&quot; age=&quot;68&quot; sex=&quot;F&quot; /&gt; &lt;visitor id=&quot;1882&quot; age=&quot;34&quot; sex=&quot;M&quot; /&gt; &lt;visitor id=&quot;5987&quot; age=&quot;23&quot; sex=&quot;M&quot; /&gt; &lt;/visitors&gt;
  </code></pre>