libxml.wasm
Demo
Installation
npm install libxml.wasm
Alternatively, you can install from GitHub Package Registry
(Optional) Build mnually
docker compose up ci
docker compose up wasm
Usage
import init from "libxml.wasm"
const libxml = await init()
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<div class="container">
<h1 class="title">Hello world</h1>
<p>Text</p>
</div>
</body>
</html>
`.trim()
const doc = libxml.parseHTML(html)
const nodes = doc.getNode("//div/h1")
const h1 = nodes[0]
console.log(h1.name)
console.log(h1.content)
console.log(h1.attr.class)