parse

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

function

function parse(xml: string, options?: ParseOptions): XmlDocument

Parses an XML string into a document tree.

xml: string

The XML string to parse.

options?: ParseOptions

Options for configuring the parser.

Returns

The parsed document.

Example: Usage

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

const doc = parse(`<root id="1"><child/></root>`);
assertEquals(doc.root.name.local, "root");
assertEquals(doc.root.attributes["id"], "1");

Source