xma

Parse xml into json or the inverse.

Usage no npm install needed!

<script type="module">
  import xma from 'https://cdn.skypack.dev/xma';
</script>

README

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.