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

@dreptin dreptin authored on 3 May 2021
docs docs: added a markdown file for the object exported when you require libxmljs-extra 1 year ago
src docs: wrote the documentation for the Document class in a markdown file + fixed some docs errors in the Document class source code 1 year ago
test test: adapted tests to the new object-oriented pattern 1 year ago
.babelrc chore: switched to babel parser to make eslint support ES6 classes better 1 year ago
.editorconfig Initial commit 1 year ago
.eslintrc.json chore: switched to babel parser to make eslint support ES6 classes better 1 year ago
.gitignore Initial commit 1 year ago
LICENSE Initial commit 1 year ago
README.md chore: fixed link formatting in readme 1 year ago
index.js docs: fixed typo in the Document class description 1 year ago
package-lock.json chore: switched to babel parser to make eslint support ES6 classes better 1 year ago
package.json chore: changed the lib description 1 year 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"

Documentation

Check the docs directory.