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.

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

5 Comments

Is it applicable Import too?
Sorry, I didn't get, Import as in?
There are codes , First Code for Json to Xml file (ur appraoch is applicable). For Second Code to read the Xml file to Json Data(Is ur approach applicable?)
Yes, you can read the xml file, convert it to json in the frontend and then pass the json data to the API
@Adritha Sharma Would you mind to look into this Question, which is related the this scenario? stackoverflow.com/questions/57708240/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.