I am very new to the babylon, i am making a GET request to my azure table and i could get the response back as a xml format by default, i am trying to convert the xml response to json by using the xml2js, but unfortunately its not happening.
Can anyone please help me how to do this?
var parser = require("xml2js");
var xml2js = new parser.Parser();
var xhr = new XMLHttpRequest();
xhr.open("GET", "link", true);
xhr.onload = function(){
console.log(xhr.responseText);
xml2js.parseString(xhr.responseText,function(err, result)
{
console.log(result);
});
};
xhr.send();
That’s quite hard to answer, as we don’t know what data is stored there and what you want to do with it.
But it seems like you are on the right track - you need to parse the XML (there are different packages to do that) and after parsing, it will be a js object that you can use in your code.
I am pretty sure you can ask azure tables to return json, but I can’t really say how
i did the same in unity , i could use the json serializer to convert it from xml to json, but here i couldnt find, even i try multiple way its throwing an error.
Can you please tell me what is the default way to convert the xml response to json?
Not mentioned on that SO link, but I can vouch for fast-xml-parser - npm (npmjs.com). I use it to convert XML to JSON - it has also a validate function. If you have well formatted XML it works well and has options for converting numbers.