How to convert data from XML to JSON


#1

How do I convert a XML file to JSON. please help me to do this friends

thank you.


#2

@Somu : I have used “R” to convert the XMl file to JSON file .
Below is the code :

++++++++++++++++++++++++++++++++++++++++++++++++++++

Required library file

library(XML)
library(methods)
library(jsonlite)

Loading the Test.xml file

result <- xmlParse(file = “Test.xml”)

Converting the xml data in to dataframe and storing it into different object

result <- xmlToDataFrame(result)

Converting the dataframe into json

result_j <- toJSON(result)

Verifying the result

cat(result_j)

Saving the file in .json file

write_json(result_j, “result.json”)

+++++++++++++++++++++++++++++++++++++++++++++++++

Hope it would help you :slight_smile: