I have an XML file with the following content:
<directory>
  <app>
    <title>Carrot</title>
    <url>www.carrot.com</url>
  </app>
  <app>
    <title>Cucumber</title>
    <url>www.cucumber.com</url>
  </app>
</directory>
Assuming I had been able to read it and store the content as a string:
s = '<directory><app><title>Carrot</title><url>www.google.com</url></app><app><title>Cucumber</title><url>www.cucumber.com</url></app></directory>';
How do I convert it to a JavaScript object like the following?
{
  "directory": {
    "app": [
      { "title": "Carrot", "url": "www.carrot.com" },
      { "title": "Cucumber", "url": "www.cucumber.com" }
    ]  
  }
}