xml-to-json-promise
Convert an XML file or XML data to JSON (via xml2js), with promises.
This module is a promise-supported wrapper around the fabulous xml2js library. This module makes it easy to convert XML files, as well as raw XML data to the JSON format.
Install
npm install --save xml-to-json-promise
Usage
var convert = ; // convert an xml file to jsonconvert; // convert raw xml data to jsonconvert;
API
convert.xmlFileToJSON(path, [options])
Converts an XML file to JSON. Returns a promise with the json data.
path
Required
Type: String
The path location to your xml file.
options
Type: object
The xml2js options you want to use when parsing the JSON.
convert.xmlDataToJSON(xml, [options])
Converts raw XML data to JSON. Returns a promise with the json data.
xml
Required
Type: String
The raw XML data you want to convert to JSON.
options
Type: object
The xml2js options you want to use when parsing the JSON.
Saving a JSON file
Here is a recipe for saving your JSON to a file using xml-to-json-promise:
var convert = ;var fs = ; convert;
Notes
This is a wrapper around the xml2js library, so please direct any issues/bugs regarding the parsing/handling of your JSON data directly to xml2js. Otherwise, feel free to open any issues if you discover a problem with this module.
License
MIT @ Michael Wuergler