Libxmljs Save

NodeJS bindings for libxml2 written in Typescript

Project README


npm version Downloads monthly Downloads total Test & Upload

npm install libxmljs

NodeJS bindings for libxml2 written in Typescript



For more examples, check out the test suite.

import libxmljs from "libxmljs";

        <?xml version="1.0" encoding="UTF-8"?>
            <child foo="bar">
            <grandchild baz="fizbuzz">grandchild content</grandchild>
            <sibling>with content!</sibling>
    .then((xmlDoc) => {
        const gchild = xmlDoc.find("//grandchild")[0];

        console.log(gchild.text()); // prints "grandchild content"

        const child = xmlDoc.root()?.child(0);

        console.log(child?.getAttribute("foo")?.value()); // prints "bar"

Package Scripts

npm run init-submodules

Clones libxml2 source code to vendor/libxml2

npm run configure

Generate new cmake config headers with cmake in vendor/libxml2.config. Used when updating to a new libxml2 version.

npm run build

Build the C++ source code using node-gyp

npm run swig

Generate a new src/ and swig.xml file by processing the native code using SWIG. Used when making changes to native code or any of the SWIG interface files (src/*.i)

npm run tsgenerate

Generates typescript definitons for native bindings exports. Used when changes are made to native exports. Auto-generates constants.ts, functions.ts, types.ts, and variables.ts within lib/bindings/

npm run tsc

Compiles Typescript within lib/ and outputs it to dist/ Use npm run dev to put Typescript compiler into watch mode.

npm run test

Runs all tests in test/ using nodeunit. Use npm run test -- -t TEST_NAME to run a specific test.

npm run docs

Generates docs/ using Typedoc

Open Source Agenda is not affiliated with "Libxmljs" Project. README Source: libxmljs/libxmljs
Open Issues
Last Commit
3 months ago

Open Source Agenda Badge

Open Source Agenda Rating