@loanlink-nl/libxmljs2
v0.0.9
Published
libxml bindings for v8 javascript engine
Readme
@loanlink-nl/libxmljs2
N-API bindings to the native libxml2 library.
Works with Node >= 20 (Bun support experimental).
Features:
- XSD validation
- RelaxNG validation
- Schematron validation
- XPath queries
- SAX parsing
- SAX push parsing
- HTML parsing
If you need anything that's included in libxml2 but not exposed by this module, don't hesitate to open an issue or to create a PR.
Usage:
import * as libxmljs from '@loanlink-nl/libxmljs2';
const xml =
'<?xml version="1.0" encoding="UTF-8"?>' +
'<root>' +
'<child foo="bar">' +
'<grandchild baz="fizbuzz">grandchild content</grandchild>' +
'</child>' +
'<sibling>with content!</sibling>' +
'</root>';
const xmlDoc = libxmljs.parseXml(xml);
const gchild = xmlDoc.get('//grandchild');
console.log(gchild.text());
// "grandchild content"
const children = xmlDoc.root().childNodes();
const child = children[0];
console.log(child.attr('foo').value());
// "bar"Changes
Compared to libxmljs and libxmljs2:
- Migrated from NAN to N-API
- Running + passing test-suite
- Support for Node >= 20
- Experimental Bun support
- Libxml2 2.15.1 (resolving 9 CVEs)
