title: Spark Dataframe with CLIXML
body: <ol>
  <li><p>I am reading a csv file from ADLSGEN2 using databricks read API.</p>
  </li>
  <li><p>The csv file contains only one column which contains Power
  Shell(clixml) content.</p>
  </li>
  <li><p>While trying to extract with spark-xml functions ,I am not getting
  the correct schema and records are  corrupted.</p>
  </li>
  <li><p>So please help me to convert the clixml to xml or exact
  solution to extract the xml content.</p>
  </li>
  </ol>
  <p>Code Block:</p>
  <pre><code>import com.databricks.spark.xml._
  import com.databricks.spark.xml.from_xml_string
  import com.databricks.spark.xml.functions.from_xml
  import org.apache.spark.sql.functions.{col}
  import org.apache.spark.sql.types.{StructType}
  import spark.implicits._
  
  var path = &quot;csvpath&quot;
  val df= spark.read
  .option(&quot;header&quot;,&quot;false&quot;)
  .option(&quot;inferschema&quot;,&quot;true&quot;)
  .csv(path)
  val dfrename= df.withColumnRenamed(&quot;_c0&quot;,&quot;xmldata&quot;)
  val xmlSchema = schema_of_xml(dfrename.select(&quot;xmldata&quot;).as[String])
  val xmlDF = dfrename.withColumn(&quot;xmldata&quot;, from_xml(col(&quot;xmldata&quot;), xmlSchema))
  display(xmlDF )
  </code></pre>
  <p>XML Content: Sample</p>
  <pre><code>&lt;Objs Version=&quot;1.1.0.1&quot; xmlns=&quot;http://schemas.microsoft.com/powershell/2004/04&quot;&gt;
    &lt;Obj RefId=&quot;0&quot;&gt;
      &lt;DT&gt;2018-03-21T08:05:39.5085956-04:00&lt;/DT&gt;
      &lt;MS&gt;
        &lt;Obj N=&quot;DisplayHint&quot; RefId=&quot;1&quot;&gt;
          &lt;TN RefId=&quot;0&quot;&gt;
            &lt;T&gt;Microsoft.PowerShell.Commands.DisplayHintType&lt;/T&gt;
            &lt;T&gt;System.Enum&lt;/T&gt;
            &lt;T&gt;System.ValueType&lt;/T&gt;
            &lt;T&gt;System.Object&lt;/T&gt;
          &lt;/TN&gt;
          &lt;ToString&gt;DateTime&lt;/ToString&gt;
          &lt;I32&gt;2&lt;/I32&gt;
        &lt;/Obj&gt;
      &lt;/MS&gt;
    &lt;/Obj&gt;
  &lt;/Objs&gt;
  </code></pre>