# libxmljs

> libxml bindings for v8 javascript engine

Latest version **1.0.11** (published 2023-10-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install libxmljs
pnpm add libxmljs
yarn add libxmljs
bun add libxmljs
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; high quality score.

Warnings: low downloads; no esm support; has vulnerabilities; large bundle.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2023-10-18 |
| First published | 2011-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=0.8.0 |
| Dependencies | 3 |
| Unpacked size | 16.8 MB |
| Known vulnerabilities | 3 |
| Install scripts | yes |
| GitHub stars | 1056 |
| Maintainers | polotek, defunctzombie, rchipka |

## Links

- npm: https://www.npmjs.com/package/libxmljs
- Repository: https://github.com/libxmljs/libxmljs
- Homepage: https://github.com/libxmljs/libxmljs#readme
- Issues: http://github.com/libxmljs/libxmljs/issues
- npm.io page: https://npm.io/package/libxmljs

## Dependencies (3)

- [nan](https://npm.io/package/nan.md) ^2.17.0
- [bindings](https://npm.io/package/bindings.md) ~1.3.0
- [@mapbox/node-pre-gyp](https://npm.io/package/@mapbox/node-pre-gyp.md) ^1.0.9

## Recent versions

- 1.0.11 (latest) — 2023-10-18
- 1.0.10 — 2023-10-09
- 1.0.9 — 2023-04-27
- 1.0.8 — 2023-04-04
- 1.0.7 — 2023-04-03
- 1.0.6 — 2023-03-31
- 1.0.4 — 2023-03-31
- 1.0.3 — 2023-03-31
- 1.0.2 — 2023-03-30
- 1.0.1 — 2023-03-29
- 1.0.0 — 2023-03-29
- 0.19.10 — 2022-05-10
- 0.19.9 — 2022-05-06
- 0.19.8 — 2022-05-04
- 0.19.7 — 2019-09-20
- … 40 more at https://npm.io/package/libxmljs/versions

## README

# libxmljs

[![npm version](https://badge.fury.io/js/libxmljs.svg)](https://badge.fury.io/js/libxmljs)
[![Downloads monthly](https://img.shields.io/npm/dm/libxmljs.svg)](https://npmjs.org/package/libxmljs)
[![Downloads total](https://img.shields.io/npm/dt/libxmljs.svg)](https://npmjs.org/package/libxmljs)
[![Test & Upload](https://github.com/libxmljs/libxmljs/actions/workflows/test-deploy.yml/badge.svg)](https://github.com/libxmljs/libxmljs/actions/workflows/test-deploy.yml)

`npm install libxmljs`

NodeJS bindings for [libxml2](https://en.wikipedia.org/wiki/Libxml2) written in
Typescript

## Documentation

[https://libxmljs.github.io/libxmljs/](https://libxmljs.github.io/libxmljs/)

## Examples

For more examples, check out the [test suite](https://github.com/libxmljs/libxmljs/tree/master/test).

```javascript
import libxmljs from "libxmljs";

libxmljs
    .parseXmlAsync(
        `
        <?xml version="1.0" encoding="UTF-8"?>
        <root>
            <child foo="bar">
            <grandchild baz="fizbuzz">grandchild content</grandchild>
            </child>
            <sibling>with content!</sibling>
        </root>
        `
    )
    .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/libxml2.cc` 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

---
_Source: https://npm.io/package/libxmljs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
