Skip to main content

Built and signed on GitHub Actions

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 Score
58%
Published
2 months 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
View transparency log

Add Package

deno add jsr:@fathym/js2xml

Import symbol

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

---- OR ----

Import directly with a jsr specifier

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

Add Package

npx jsr add @fathym/js2xml

Import symbol

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

Add Package

yarn dlx jsr add @fathym/js2xml

Import symbol

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

Add Package

pnpm dlx jsr add @fathym/js2xml

Import symbol

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

Add Package

bunx jsr add @fathym/js2xml

Import symbol

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