I am trying to use the Treeview directive from AngularJS. The stored procedure returns xml. The tree view directive accepts the json format. The controller will receive data from the service. I am stuck trying to convert xml to json in service.
The following is the xml structure:
<Company Data="New Company"> <Manager Data="Working"> <Employee Data="ABC" /> <Employee Data="DEF" /> <Employee Data="GHI"> <SubEmployee Data="Approval"> <Stuff Data="Financial" /> <Stuff Data="Consol" /> </SubEmployee> <SubEmployee Data="Rolled-Over"> <Stuff Data="Corporate" /> </SubEmployee> </Employee> </Manager> </Company>
Below is the expected JSON:
[ { 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: [ ] } ] } ] } ] } ]
user3083626
source share