I want to convert an xml to a JSON. Example: convert the below xml to the json given.
<header>
<students>
<info>
<name>student1</name>
<class>2</class>
</info>
<info>
<name>student2</name>
<class>3</class>
</info>
</students>
</header>
JSON:
{
"header": {
"students": [
{
"name": "student1",
"class": "2"
},
{
"name": "student2",
"class": "3"
}
]
}
}
The question is, how do i convert the element into the array?