Library to complement libxmljs and especially make namespaces easier to deal with.

dreptin authored on 25 Jun
docs docs: added a markdown file for the object exported when you require libxmljs-extra 7 months ago
src feat: added default parser options to parsing methods to remove the blanks by default + changed the eslint config 6 months ago
test feat: added default parser options to parsing methods to remove the blanks by default + changed the eslint config 6 months ago
.babelrc chore: switched to babel parser to make eslint support ES6 classes better 7 months ago
.editorconfig Initial commit 7 months ago
.eslintrc.json feat: added default parser options to parsing methods to remove the blanks by default + changed the eslint config 6 months ago
.gitignore Initial commit 7 months ago
LICENSE Initial commit 7 months ago
README.md docs: added a disclaimer about the segmentation fault signals in README.md 5 months ago
index.js docs: fixed typo in the Document class description 7 months ago
package-lock.json feat: added default parser options to parsing methods to remove the blanks by default + changed the eslint config 6 months ago
package.json feat: added default parser options to parsing methods to remove the blanks by default + changed the eslint config 6 months ago
README.md

libxmljs-extra

Library to complement libxmljs and especially make namespaces easier to deal with.

Basic example

const { Document } = require('libxmljs-extra');

const xml = `<?xml version="1.0" encoding="UTF-8"?>
            <root xmlns="http://www.my-namespace.org/">
              <child>
                <grandchild>Hello</grandchild>
              </child>
              <child>
                <grandchild>World</grandchild>
              </child>
            </root>`;

const xmlDoc = new Document(xml);

// Sets the global namespace of the document
xmlDoc.setNamespace('namespace', 'http://www.my-namespace.org/');

const grandchildren = xmlDoc.find('//grandchild');

grandchildren.forEach((grandchild) => console.log(grandchild.text())); // Prints "Hello\nWorld"

console.log(xmlDoc.count('//grandchild')); // Prints "2"

Disclaimer

We (the ISTEX team) noticed some critical bugs related to libxmljs. Some of our documents (we were not able to identify them precisely) generate segmentation fault signals. This happens very rarely but we thought it was worth mentioning.

Documentation

Check the docs directory.