1

I am setting up a Xml Export functionality, whose function is to convert Json data from DB to Xml and save as .xml file in specific folder.

I tried this link https://shekhargulati.com/2017/07/16/implementing-file-save-functionality-with-angular-4/ but don't save as .Xml file.

I already converted the Json data to Xml data using this code

 this.ordertemplateService.GetOrderTemplate().subscribe((res: any) => {
        console.log(res.data);
        var jxmlparser = require('js2xmlparser');
        if (res != null) {
          result = jxmlparser.parse('OrderTemplate',res.data);
          console.log('back to xml -> %s', result);
}

and the Import too(XML to JSON).

let parseString = require('xml2js').parseString;
       let xml = "<root>Hello xml2js!</root>"

       parseString(xml, function (err, result) {
         console.dir(result);
}

But don't know how to move forward. Please brainstorm me with your knowledge.

Adrita Sharma
  • 21,581
  • 10
  • 69
  • 79
Sarath Mohandas
  • 472
  • 1
  • 9
  • 25

1 Answers1

1

You cannot save any file from frontend (Angular, Javascript etc) to a specific folder.

Create an API in backend(nodeJs, Php,Java etc), pass the xml Data to it, and then save the file in the desired location

Adrita Sharma
  • 21,581
  • 10
  • 69
  • 79