title: Convert XML Data to Json Format AngularJS
body: <p>I am trying to use Treeview directive from AngularJS. The stored procedure is returning      xml.The tree view directive takes json format. The Controller will get the data from service.I am stuck trying to convert xml to json in service.</p>
  
  <p>Following is the xml structure:</p>
  
  <pre><code>&lt;Company Data="New Company"&gt;
    &lt;Manager Data="Working"&gt;
      &lt;Employee Data="ABC" /&gt;
      &lt;Employee Data="DEF" /&gt;
      &lt;Employee Data="GHI"&gt;
        &lt;SubEmployee Data="Approval"&gt;
          &lt;Stuff Data="Financial" /&gt;
          &lt;Stuff Data="Consol" /&gt;
        &lt;/SubEmployee&gt;
        &lt;SubEmployee Data="Rolled-Over"&gt;
          &lt;Stuff Data="Corporate" /&gt;
        &lt;/SubEmployee&gt;
      &lt;/Employee&gt;
    &lt;/Manager&gt;
  &lt;/Company&gt;
  </code></pre>
  
  <p>Below is the expected JSON :</p>
  
  <pre><code>[
    {
      label: "New Company",
      id: "Company",
      children: [
        {
          label: "Working",
          id: "Manager",
          children: [
            {
              label: "ABC",
              id: "Employee",
              children: [
  
              ]
            },
            {
              label: "DEF",
              id: "Employee",
              children: [
  
              ]
            },
            {
              label: "GHI",
              id: "Employee",
              children: [
                {
                  label: "Approval",
                  id: "SubEmployee",
                  children: [
                    {
                      label: "Financial",
                      id: "Stuff",
                      children: [
  
                      ]
                    },
                    {
                      label: "Consol",
                      id: "Stuff",
                      children: [
  
                      ]
                    }
                  ]
                },
                {
                  label: "RolledOver",
                  id: "SubEmployee",
                  children: [
                    {
                      label: "Corporate",
                      id: "Stuff",
                      children: [
  
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
  </code></pre>