title: How to parse XML using databricks in Spark Java
body: <p>I need to parse XML file using databricks in Spark. </p>
  
  <p>I want to show the result for attribute Count=7.</p>
  
  <blockquote>
    <p>I want to get the output: 
    soccer</p>
  </blockquote>
  
  <p>Here is my XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;tags&gt;
  &lt;row Id="1" TagName="soccer" Count="7" ExcerptPostId="12371" WikiPostId="12370" /&gt;
  &lt;row Id="2" TagName="servos" Count="63" ExcerptPostId="186" WikiPostId="185" /&gt;
  &lt;row Id="3" TagName="control" Count="394" ExcerptPostId="192" WikiPostId="191" /&gt;
  &lt;row Id="5" TagName="gait" Count="4" ExcerptPostId="12362" WikiPostId="12361" /&gt;
  &lt;/tags&gt;
  </code></pre>
  
  <p>My Main class (but it doesn't work properly):</p>
  
  <pre><code>import org.apache.spark.api.java.function.FilterFunction;
  import org.apache.spark.sql.SparkSession;
  import org.apache.spark.sql.Dataset;
  import org.apache.spark.sql.Row;
  import org.apache.spark.sql.SQLContext;
  import com.databricks.spark.xml.XmlReader;
  
  public class SimpleApp {
  public static void main(String[] args) {
  
      String someFile = "/home/files/Tags.xml";
  
      SparkSession spark = SparkSession.builder().appName("Simple app").getOrCreate();
  
      Dataset&lt;String&gt; logData = spark.read().textFile(someFile).cache();
  
      SQLContext sqlContext = new SQLContext(sc);
      Dataset&lt;Row&gt; df = sqlContext.read.xml("/home/files/Tags.xml");
      DataFrame df = sqlContext.read()
              .format("com.databricks.spark.xml")
              .option("tags", "Count")
              .load("/home/files/Tags.xml");
  
      df.select("TagName", "Count").write()
              .format("com.databricks.spark.xml")
              .option("tags", "TagName")
              .save("/home/files/Tags.xml");
  
          spark.stop();
      }
  }
  </code></pre>
  
  <p>Thank you in advance</p>