Skip to main content
Home

Built and signed on GitHub Actions

Works with
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score58%
Published2 years ago (0.0.12)

Convert JavaScript objects to XML

js2xml utility ported to Deno from xml-js library.

This library has no dependencies.

See [https://deno.land/x/xml2js] for parsing XML into objects.

Usage example

import { js2xml } from "https://deno.land/x/js2xml@1.0.3/mod.ts";

const obj = {
  foo: {
    bar: {
      _text: "41",
    },
    baz: {
      _attributes: {
        boo: "42",
      },
      baa: {
        _cdata: "43",
      },
    },
  },
};

const xml = js2xml(obj, {
  compact: true,
  spaces: 4,
});

console.log(xml);

Output:

<foo>
    <bar>41</bar>
    <baz boo="42">
        <baa><![CDATA[43]]></baa>
    </baz>
</foo>

License information

This project is released under the Apache License 2.0.

Built and signed on
GitHub Actions

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@fathym/js2xml

Import symbol

import * as js_xml from "@fathym/js2xml";
or

Import directly with a jsr specifier

import * as js_xml from "jsr:@fathym/js2xml";

Add Package

pnpm i jsr:@fathym/js2xml
or (using pnpm 10.8 or older)
pnpm dlx jsr add @fathym/js2xml

Import symbol

import * as js_xml from "@fathym/js2xml";

Add Package

yarn add jsr:@fathym/js2xml
or (using Yarn 4.8 or older)
yarn dlx jsr add @fathym/js2xml

Import symbol

import * as js_xml from "@fathym/js2xml";

Add Package

vlt install jsr:@fathym/js2xml

Import symbol

import * as js_xml from "@fathym/js2xml";

Add Package

npx jsr add @fathym/js2xml

Import symbol

import * as js_xml from "@fathym/js2xml";

Add Package

bunx jsr add @fathym/js2xml

Import symbol

import * as js_xml from "@fathym/js2xml";