How would you convert from XML to JSON and then back to XML?
The following tools work quite well, but aren\'t completely consistent:
I was using xmlToJson just to get a single value of the xml.
I found doing the following is much easier (if the xml only occurs once..)
let xml =
'' +
' 762384324 ' +
' Hank ' +
' Stone ' +
' ';
let getXmlValue = function(str, key) {
return str.substring(
str.lastIndexOf('<' + key + '>') + ('<' + key + '>').length,
str.lastIndexOf('' + key + '>')
);
}
alert(getXmlValue(xml, 'firstname')); // gives back Hank