import { parse } from "https://deno.land/x/xml@4.0.0/mod.ts";
XML parser
Parse a string
or a Flux stream into a document.
Parsed attributes will be prefixed with @
, while comments will be stored in #comment
property and content in #text
.
If a node does not possess any attribute or comments, then it will be flattened into its text content for convenience.
ParserOptions can be used to customize the parser behavior.
Examples
Example 1
Example 1
import { parse } from "./parse.ts"
console.log(parse(
`
<root>
<!-- This is a comment -->
<text>hello</text>
<array>world</array>
<array>monde</array>
<array>ไธ็</array>
<array>๐</array>
<number>42</number>
<boolean>true</boolean>
<complex attribute="value">content</complex>
</root>
`,
{ reviveNumbers: true, reviveBooleans: true },
))