Comment = function (doc, content) {
if (!doc) {
throw new Error('document argument required');
} else if (! (doc instanceof bindings.Document)) {
throw new Error('document argument must be an ' +
'instance of Document');
}
return new bindings.Comment(doc, content);
}n/a
function Document(version, encoding) {
version = version || '1.0';
var doc = new bindings.Document(version);
doc.encoding(encoding || 'utf8');
return doc;
}n/a
function Element(doc, name, content) {
if (!doc) {
throw new Error('document argument required');
} else if (! (doc instanceof bindings.Document)) {
throw new Error('document argument must be an ' +
'instance of Document');
} else if (!name) {
throw new Error('name argument required');
}
return new bindings.Element(doc, name, content);
}n/a
SaxParser = function (callbacks) {
var parser = new bindings.SaxParser();
// attach callbacks
for (var callback in callbacks) {
parser.on(callback, callbacks[callback]);
}
return parser;
}...
var events = require('events');
var bindings = require('./bindings');
var SaxParser = function(callbacks) {
var parser = new bindings.SaxParser();
// attach callbacks
for (var callback in callbacks) {
parser.on(callback, callbacks[callback]);
}
return parser;
...SaxPushParser = function (callbacks) {
var parser = new bindings.SaxPushParser();
// attach callbacks
for (var callback in callbacks) {
parser.on(callback, callbacks[callback]);
}
return parser;
}...
// Overriding the prototype, like util.inherit, wipes out the native binding.
// Copy over the methods instead.
for (var k in events.EventEmitter.prototype)
bindings.SaxParser.prototype[k] = events.EventEmitter.prototype[k];
var SaxPushParser = function(callbacks) {
var parser = new bindings.SaxPushParser();
// attach callbacks
for (var callback in callbacks) {
parser.on(callback, callbacks[callback]);
}
return parser;
...function Text(doc, content) {
if (!doc) {
throw new Error('document argument required');
}
if (!(doc instanceof bindings.Document)) {
throw new Error('document argument must be an instance of Document');
}
if (!content) {
throw new Error('content argument required');
}
return new bindings.Text(doc, content);
}n/a
function xmlMemUsed() { [native code] }n/a
function xmlNodeCount() { [native code] }n/a
parseHtml = function (string, opts) {
opts = opts || {};
// if for some reason user did not specify an object for the options
if (typeof(opts) !== 'object') {
throw new Error('fromHtml options must be an object');
}
return bindings.fromHtml(string, opts);
}n/a
parseHtmlFragment = function (string, opts) {
opts = opts || {};
// if for some reason user did not specify an object for the options
if (typeof(opts) !== 'object') {
throw new Error('fromHtmlFragment options must be an object');
}
opts.doctype = false;
opts.implied = false;
return bindings.fromHtml(string, opts);
}n/a
parseHtmlString = function (string, opts) {
opts = opts || {};
// if for some reason user did not specify an object for the options
if (typeof(opts) !== 'object') {
throw new Error('fromHtml options must be an object');
}
return bindings.fromHtml(string, opts);
}n/a
parseXml = function (string, options) {
return bindings.fromXml(string, options || {});
}...
'<root>' +
'<child foo="bar">' +
'<grandchild baz="fizbuzz">grandchild content</grandchild>' +
'</child>' +
'<sibling>with content!</sibling>' +
'</root>';
var xmlDoc = libxmljs.parseXml(xml);
// xpath queries
var gchild = xmlDoc.get('//grandchild');
console.log(gchild.text()); // prints "grandchild content"
var children = xmlDoc.root().childNodes();
...parseXmlString = function (string, options) {
return bindings.fromXml(string, options || {});
}n/a
Comment = function (doc, content) {
if (!doc) {
throw new Error('document argument required');
} else if (! (doc instanceof bindings.Document)) {
throw new Error('document argument must be an ' +
'instance of Document');
}
return new bindings.Comment(doc, content);
}n/a
function text() { [native code] }...
'</root>';
var xmlDoc = libxmljs.parseXml(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"
```
...function Document(version, encoding) {
version = version || '1.0';
var doc = new bindings.Document(version);
doc.encoding(encoding || 'utf8');
return doc;
}n/a
fromHtml = function (string, opts) {
opts = opts || {};
// if for some reason user did not specify an object for the options
if (typeof(opts) !== 'object') {
throw new Error('fromHtml options must be an object');
}
return bindings.fromHtml(string, opts);
}n/a
fromHtmlFragment = function (string, opts) {
opts = opts || {};
// if for some reason user did not specify an object for the options
if (typeof(opts) !== 'object') {
throw new Error('fromHtmlFragment options must be an object');
}
opts.doctype = false;
opts.implied = false;
return bindings.fromHtml(string, opts);
}n/a
fromHtmlString = function (string, opts) {
opts = opts || {};
// if for some reason user did not specify an object for the options
if (typeof(opts) !== 'object') {
throw new Error('fromHtml options must be an object');
}
return bindings.fromHtml(string, opts);
}n/a
fromXml = function (string, options) {
return bindings.fromXml(string, options || {});
}n/a
fromXmlString = function (string, options) {
return bindings.fromXml(string, options || {});
}n/a
function _encoding() { [native code] }n/a
function _getDtd() { [native code] }n/a
function _rngValidate() { [native code] }n/a
function _root() { [native code] }n/a
function _setDtd() { [native code] }n/a
function _toString() { [native code] }n/a
function _validate() { [native code] }n/a
function _version() { [native code] }n/a
child = function (id) {
if (id === undefined || typeof id !== 'number') {
throw new Error('id argument required for #child');
}
assertRoot(this);
return this.root().child(id);
}n/a
childNodes = function () {
assertRoot(this);
return this.root().childNodes();
}...
var xmlDoc = libxmljs.parseXml(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"
```
## Support
...encoding = function (encoding) {
return this._encoding(encoding);
}n/a
find = function (xpath, ns_uri) {
assertRoot(this);
return this.root().find(xpath, ns_uri);
}n/a
get = function (xpath, ns_uri) {
assertRoot(this);
return this.root().get(xpath, ns_uri);
}...
'</child>' +
'<sibling>with content!</sibling>' +
'</root>';
var xmlDoc = libxmljs.parseXml(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"
...getDtd = function () {
return this._getDtd();
}n/a
namespaces = function () {
assertRoot(this);
return this.root().namespaces();
}n/a
node = function (name, content) {
return this.root(Element(this, name, content));
}n/a
rngValidate = function (rng) {
return this._rngValidate(rng);
}n/a
root = function (elem) {
return this._root(elem);
}...
var xmlDoc = libxmljs.parseXml(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"
```
## Support
...setDtd = function (name, ext, sys) {
if (!name) {
throw new Error('Must pass in a DTD name');
} else if (typeof name !== 'string') {
throw new Error('Must pass in a valid DTD name');
}
var params = [name];
if (typeof ext !== 'undefined') {
params.push(ext);
}
if (ext && typeof sys !== 'undefined') {
params.push(sys);
}
return this._setDtd.apply(this, params);
}n/a
toString = function (formatted) {
return this._toString(formatted !== undefined ? formatted : true);
}n/a
type = function () {
return 'document';
}n/a
validate = function (xsd) {
return this._validate(xsd);
}n/a
version = function () {
return this._version();
}n/a
function Element(doc, name, content) {
if (!doc) {
throw new Error('document argument required');
} else if (! (doc instanceof bindings.Document)) {
throw new Error('document argument must be an ' +
'instance of Document');
} else if (!name) {
throw new Error('name argument required');
}
return new bindings.Element(doc, name, content);
}n/a
function _attr() { [native code] }n/a
function addCData() { [native code] }n/a
function addChild() { [native code] }n/a
function addNextSibling() { [native code] }n/a
function addPrevSibling() { [native code] }n/a
attr = function () {
if (arguments.length === 1) {
var arg = arguments[0];
if (typeof arg === 'object') {
// object setter
// iterate keys/value to set attributes
for (var k in arg) {
this._attr(k, arg[k]);
};
return this;
} else if (typeof arg === 'string') {
// getter
return this._attr(arg);
}
} else if (arguments.length === 2) {
// 2 arg setter
var name = arguments[0];
var value = arguments[1];
this._attr(name, value);
return this;
}
}...
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"
```
## Support
* Docs - [http://github.com/libxmljs/libxmljs/wiki](http://github.com/libxmljs/libxmljs/wiki)
* Mailing list - [http://groups.google.com/group/libxmljs](http://groups.google.com/group/libxmljs)
...function attrs() { [native code] }n/a
cdata = function (content) {
this.addCData(content);
return this;
}n/a
function child() { [native code] }n/a
function childNodes() { [native code] }...
var xmlDoc = libxmljs.parseXml(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"
```
## Support
...defineNamespace = function (prefix, href) {
// if no prefix specified
if (!href) {
href = prefix;
prefix = null;
}
return new bindings.Namespace(this, prefix, href);
}n/a
function find() { [native code] }n/a
get = function () {
var res = this.find.apply(this, arguments);
if (res instanceof Array) {
return res[0];
} else {
return res;
}
}...
'</child>' +
'<sibling>with content!</sibling>' +
'</root>';
var xmlDoc = libxmljs.parseXml(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"
...function name() { [native code] }n/a
function nextElement() { [native code] }n/a
node = function (name, content) {
var elem = Element(this.doc(), name, content);
this.addChild(elem);
return elem;
}n/a
function path() { [native code] }n/a
function prevElement() { [native code] }n/a
function replace() { [native code] }n/a
function text() { [native code] }...
'</root>';
var xmlDoc = libxmljs.parseXml(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"
```
...function Text(doc, content) {
if (!doc) {
throw new Error('document argument required');
}
if (!(doc instanceof bindings.Document)) {
throw new Error('document argument must be an instance of Document');
}
if (!content) {
throw new Error('content argument required');
}
return new bindings.Text(doc, content);
}n/a
function nextElement() { [native code] }n/a
function prevElement() { [native code] }n/a
function replace() { [native code] }n/a
function text() { [native code] }...
'</root>';
var xmlDoc = libxmljs.parseXml(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"
```
...Attribute = function () { [native code] }n/a
Comment = function () { [native code] }n/a
function Document() { [native code] }n/a
Element = function () { [native code] }n/a
Namespace = function () { [native code] }n/a
SaxParser = function () { [native code] }...
var events = require('events');
var bindings = require('./bindings');
var SaxParser = function(callbacks) {
var parser = new bindings.SaxParser();
// attach callbacks
for (var callback in callbacks) {
parser.on(callback, callbacks[callback]);
}
return parser;
...SaxPushParser = function () { [native code] }...
// Overriding the prototype, like util.inherit, wipes out the native binding.
// Copy over the methods instead.
for (var k in events.EventEmitter.prototype)
bindings.SaxParser.prototype[k] = events.EventEmitter.prototype[k];
var SaxPushParser = function(callbacks) {
var parser = new bindings.SaxPushParser();
// attach callbacks
for (var callback in callbacks) {
parser.on(callback, callbacks[callback]);
}
return parser;
...Text = function () { [native code] }n/a
function fromHtml() { [native code] }n/a
function fromXml() { [native code] }n/a
function xmlMemUsed() { [native code] }n/a
function xmlNodeCount() { [native code] }n/a
SaxParser = function (callbacks) {
var parser = new bindings.SaxParser();
// attach callbacks
for (var callback in callbacks) {
parser.on(callback, callbacks[callback]);
}
return parser;
}...
var events = require('events');
var bindings = require('./bindings');
var SaxParser = function(callbacks) {
var parser = new bindings.SaxParser();
// attach callbacks
for (var callback in callbacks) {
parser.on(callback, callbacks[callback]);
}
return parser;
...SaxPushParser = function (callbacks) {
var parser = new bindings.SaxPushParser();
// attach callbacks
for (var callback in callbacks) {
parser.on(callback, callbacks[callback]);
}
return parser;
}...
// Overriding the prototype, like util.inherit, wipes out the native binding.
// Copy over the methods instead.
for (var k in events.EventEmitter.prototype)
bindings.SaxParser.prototype[k] = events.EventEmitter.prototype[k];
var SaxPushParser = function(callbacks) {
var parser = new bindings.SaxPushParser();
// attach callbacks
for (var callback in callbacks) {
parser.on(callback, callbacks[callback]);
}
return parser;
...