xma
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

xma Travis CI Build Status

Parse xml into json or the inverse.

NPM Badge

Install

npm install xma

Usage

const { parseXml, buildXml } = require("xma");
 
parseXml("<root>Hello World</root>");
//=> { root: "Hello World" }
 
parseXml(`<root foo="bar">Hello World</root>`);
//=> { root: { _: "Hello World", $: { foo: "bar" } } }
 
buildXml({ root: "Hello World" });
//=> "<root>Hello World</root>"
 
buildXml({ root: { _: "Hello World", $: { foo: "bar" } } });
//=> "<root foo="bar">Hello World</root>"

API

parseXml(xmlString, options?)

Parse xml into json.

xmlString

Type: string

The xml to parse.

options

Type: object

The options to pass to xml2js.

buildXml(xmlObject, options?)

Build xml from json.

xmlObject

Type: string

The json object to build.

options

Type: object

The options to pass to xml2js.

Package Sidebar

Install

npm i xma

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

5.34 kB

Total Files

6

Last publish

Collaborators

  • richienb