title: Read XML file to a Spark dataframe
body: <p>I have an XML file in the below format.</p>
  
  <pre><code>&lt;LEVEL1 A1="a1" A2="a2" A3="ss"&gt;
    &lt;LEVEL2 A1="a1" A2="a2" A3="a3"&gt;
      &lt;LEVEL3&gt;
        &lt;ITEM A1="a1" A2="a2" A3="a3"/&gt;
        &lt;ITEM A1="b1" A2="22" A3="b3"/&gt;
        &lt;ITEM A1="c1" A2="c2" A3="c3"/&gt;
      &lt;/LEVEL3&gt;
    &lt;/LEVEL2&gt;
  &lt;/LEVEL1&gt;
  </code></pre>
  
  <p>I need to load this file into a Spark dataframe using PySpark and access the various nodes and attributes.</p>
  
  <p>I have tried loading the XML file into a Spark dataframe using the below code. The code runs without errors, but seems like the dataframe is empty.</p>
  
  <pre><code>df1 = spark.read.format('xml').options(rowTag='LEVEL1').load('sample.xml')
  df2 = spark.read.format('xml').options(rowTag='LEVEL2').load('sample.xml')
  df3 = spark.read.format('xml').options(rowTag='LEVEL3').load('sample.xml')
  df1.show()
  df2.show()
  df3.show()
  </code></pre>
  
  <p>Any help in loading this file to a dataframe is appreciated. Thanks.</p>