1.2.1 • Published 1 year ago

egg-plugin-xml v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

egg-plugin-xml

An eggjs plugin for parsing xml

NPM version Codacy Badge Known Vulnerabilities npm download License

Sonar

Install

# use pnpm
$ pnpm install egg-plugin-xml

# use yarn
$ yarn add egg-plugin-xml

Usage

// {app_root}/config/plugin.js
exports.xmlParser = {
  enable: true,
  package: 'egg-plugin-xml'
}

Configuration

egg-plugin-xml support all configurations in xml2js.

eg. Do not always put child nodes in an array

// {app_root}/config/config.default.js
exports.xmlParser = {
  limit: '2mb',
  encoding: 'utf8',
  key: 'body',
  xmlOptions: {
    explicitArray: false
  }
}

eg. Convert camel to underscore delimited

// {app_root}/config/config.default.js
exports.xmlParser = {
  normalizeTags: true // or: normalizeTags: '-'
}

Extends

// {app_root}/app/extend/helper.js
const { helper } = ctx

helper.parserXML()
helper.getXMLBody()

Change logs

Change logs

Questions & Suggestions

Please open an issue here.

License

MIT