简体   繁体   中英

Angular 8 Create an XML file from form values

Problem I have angular 8 app that has different forms.

The user choose a form and fills it. When submit the form I need to create a xml file with the values from the form, that the user can download, so that he can import it to another platform. This app only objective is to generate that xml file.

So my question is: How do I do this only with angular, I don't want to develop a node.js api to do that or any type of back-end. Also I already search the web for it and found the angular-xml package but it's for converting JSON to XMl, not to generate an xml file. So how do I do this?

You can create a function on the front end app that converts the form value into XML using the names of the controls as the element tags. You can then use the FileSaver library to generate and download a file from the XML string you created

The only way to do it is, you have to create server app to create file on your disk because for security reasons it is impossible to create a file on your disk from (angular app) or any other web app that runs on browsers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM