title: XML to JSON with Scala
body: <p>For a XML snippet like this:</p>
  
  <pre><code>val fruits =
  &lt;fruits&gt;
    &lt;fruit&gt;
      &lt;name&gt;apple&lt;/name&gt;
      &lt;taste&gt;ok&lt;/taste&gt;
    &lt;/fruit&gt;
    &lt;fruit&gt;
      &lt;name&gt;banana&lt;/name&gt;
      &lt;taste&gt;better&lt;/taste&gt;
    &lt;/fruit&gt;
  &lt;/fruits&gt;
  </code></pre>
  
  <p>doing something like:</p>
  
  <pre><code>fruits \\ "fruit"
  </code></pre>
  
  <p>will return a sequence of type <code>scala.xml.NodeSeq</code> with all the fruits and sub nodes inside.</p>
  
  <p>What is the best way to convert this to a list of JSON objects? I'm trying to send my list of fruits back to a browser. I had a look at <code>scala.util.parsing.json.JSONObject</code> and <code>scala.util.parsing.json.JSONArray</code>, but I don't know how to get from NodeSeq to anyone of the latter.</p>
  
  <p>If at all possible, I would love to see how it's done with plain Scala code.</p>