Extracting tag attributes from xml using sparkxml
I am loading a xml file using com.databricks.spark.xml and i want to read a tag attribute using the sql context . XML : <Receipt> <Sale> <DepartmentID>PR</DepartmentID> <Tax TaxExempt="false" TaxRate="10.25"/> </Sale> </Receipt> Loaded the file by, val df = sqlContext.read.format("com.databricks.spark.xml").option("rowTag","Receipt").load("/home/user/sale.xml"); df.registerTempTable("SPtable"); Printing the Schema: root |-- Sale: array (nullable = true) | |-- element: struct (containsNull = true) | | |-- DepartmentID: long (nullable = true) | | |-- Tax: string (nullable = true) Now i want to