stringify

import { stringify } from "jsr:@ende/xml";

function

function stringify(node: XmlDocument | XmlElement, options?: StringifyOptions): string

Converts an XML document or element to an XML string.

node: XmlDocument | XmlElement

The document or element to serialize.

options?: StringifyOptions

Options for configuring the serialization.

Returns

The serialized XML string.

Example: Usage

import { stringify } from "@ende/xml/stringify";
import { assertEquals } from "@ende/assert";

const element = {
  type: "element" as const,
  name: { raw: "root", local: "root" },
  attributes: {},
  children: [{ type: "text" as const, text: "Hello!" }],
};

assertEquals(stringify(element), "<root>Hello!</root>");

Source