XML Module

Simple xml/json conversion tool.

Import

import xml from 'xml';

Methods

toJs(xml) toXml(json, options)

toJs(xml)

Parses xml into a json object.

Arguments

  • XML (String) an xml input string

Returns

JSON Object

toXml(json, options)

Converts a json object to an xml document.

Arguments

  • json (Object) a json input object.

  • options (Object)

    • rootElement (String: root)

    • prettyPrint (Boolean: false)

    • indent (String: \t)

    • newline (String: \n)

    • version (String: 1.0)

    • encoding (String: UTF-8)

    • standalone (Boolean: true)

    • doctype (String: null)

    • headless (Boolean: false)

Returns

XML Document String

Examples

toJS

Example

toJS

Example Response

toXml

Example

toXml

Example Response

Last updated

Was this helpful?