Closed neilpalima closed 4 years ago
Yes, you must read the file before calling FHIR.js, though. Here is an example... Maybe not perfect, cause I'm writing this off of memory, but should get you going in the right direction.
var fs = require('fs');
var {Fhir} = require('fhir');
var sourceXmlFile = 'path to source xml';
var destJsonFile = 'path to destination json';
var fhir = new Fhir();
var xml = fs.readFileSync(sourceXmlFile);
var obj = fhir.xmlToObj(xml);
var json = JSON.stringify(obj, null, '\t');
fs.writeFileSync(destJsonFile, json);
Is there a way to convert a fhir xml file to json? On your example it always starts from a json object.
We have a fhir xml file that needs to be converted to a json.