Skip to content
This repository

libxml bindings for v8 javascript engine

tree: 7fdf7fc909

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 docs
Octocat-spinner-32 lib
Octocat-spinner-32 src
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore move to node::ObjectWrap over custom version December 19, 2011
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 LICENSE add license September 24, 2009
Octocat-spinner-32 Makefile
Octocat-spinner-32 README.md
Octocat-spinner-32 binding.gyp
Octocat-spinner-32 index.js
Octocat-spinner-32 package.json
Octocat-spinner-32 wscript support multiple include paths in xml2-config January 25, 2012
README.md

Libxmljs

Build Status

LibXML bindings for node.js

var libxmljs = require("libxmljs");
var xml =  '<?xml version="1.0" encoding="UTF-8"?>' +
           '<root>' +
               '<child foo="bar">' +
                   '<grandchild baz="fizbuzz">grandchild content</grandchild>' +
               '</child>' +
               '<sibling>with content!</sibling>' +
           '</root>';

var xmlDoc = libxmljs.parseXmlString(xml);

// xpath queries
var gchild = xmlDoc.get('//grandchild');

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

var children = xmlDoc.root().childNodes();
var child = children[0];

console.log(child.attr('foo').value()); // prints "bar"

CDATA Example by Dudochkin Victor blacksmith@gogoo.ru:

var util = require('util');
var libxml = require('libxmljs');

var doc = libxml.Document();
var elem = doc.node('name1');
var newChild = libxml.Element(doc, 'new-child');
elem.addChild(newChild);


var child1 = elem.node('child1');
var child2 = elem.node('child2', 'second');
var newChild = libxml.Element(doc, 'new-child');
var name2 = elem.node('name2');
name2.addChild(newChild);
child2.cdata('<h1>cdata test</h1>').cdata('<p>It\'s worked</p>').cdata('<hr/>All done');
util.puts('Document With CDATA: ' + doc.toString());

Basics

API and Examples

Check out the wiki http://github.com/polotek/libxmljs/wiki

Requirements

You will need have the libxml2 library installed and also the libxml2-devel (libxml2-dev on debian systems) package. This comes with the xml2-config utility that is needed for compiling. This command must be in your path.

Installation

npm

npm install libxmljs

source

To build with node waf:

node-gyp configure
node-gyp build

Alternatively, run make.

tests

npm test
Something went wrong with that request. Please try again.