1.0.0 • Published 4 years ago

xma v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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.