| 123456789101112131415161718 |
- const xml2js = require('xml2js')
- const XML = {
- parse(string) {
- let result = null
- xml2js.parseString(string, (err, doc) => {
- if (err) throw err
- result = doc
- })
- if (!result) throw new Error('Async?')
- return result
- },
- stringify(doc) {
- const builder = new xml2js.Builder()
- return builder.buildObject(doc)
- }
- }
- module.exports = XML
|