Create an XML file using JavaScript

xiaoxiao2021-03-06  14

Creating an XML file in the client You can use the FileSystemObject (FSO) object or use XML Document Object Model (DOM). If you use FSO, the client must install Window Script 5.5, using XML DOM, you need to install Microsoft® XML Core Services on the client. Security needs to enable ActiveX controls in the IE security settings.

1. Create an XML file using FSO

Use the GetSpecialFolder method for the FSO object to get the directory where you want to create files (settings for the GetSpecialFolder method), see the Window script technology document), then create a text file using the CreateTextFile method and get a reference to this file, calling text file objects. The WriteLine method writes content in the file and finally closes the object.

It is worth noting that when using CreateTextFile creation file, the last indicator file creation method should be set to True to represent in Unicode mode, and set the XML file encoding to UTF-16, which creates the XML file to be used normally .