function to convert xml to json and save to db