Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update local docs

  • Loading branch information...
commit b24f04bb40c3b343c465afd330caa79683558c1e 1 parent 72464eb
Marco Rogers authored
184 docs/Home.md
View
@@ -2,26 +2,28 @@
LibXML bindings for [node.js](http://nodejs.org/)
- 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>';
+```javascript
+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.parseXml(xml);
+var xmlDoc = libxmljs.parseXmlString(xml);
- // xpath queries
- var gchild = xmlDoc.get('//grandchild');
+// xpath queries
+var gchild = xmlDoc.get('//grandchild');
- console.log(gchild.text()); // prints "grandchild content"
+console.log(gchild.text()); // prints "grandchild content"
- var children = xmlDoc.root().childNodes();
- var child = children[0];
+var children = xmlDoc.root().childNodes();
+var child = children[0];
- console.log(child.attr('foo').value()); // prints "bar"
+console.log(child.attr('foo').value()); // prints "bar"
+```
## API
@@ -40,130 +42,70 @@ Check out some examples on parsing and building xml documents below.
### Builder
-There are two main ways to use the builder. The first:
+To build an XML document simply create all the required nodes (indentation is meant to represent location in the tree, you can capture any intermediate variable to reuse):
- var doc = new libxml.Document(function(n) {
- n.node('root', function(n) {
- n.node('child', {foo: 'bar'}, function(n) {
- n.node('grandchild', {baz: 'fizbuzz'}, 'grandchild content');
- });
- n.node('sibling', 'with content!');
- });
- });
+```javascript
+var doc = new libxml.Document();
+ doc.node('root')
+ .node('child').attr({foo: 'bar'})
+ .node('grandchild', 'grandchild content').attr({baz: 'fizbuzz'})
+ .parent()
+ .parent()
+ .node('sibling', 'with content!');
+```
Calling doc.toString() will yield the following XML:
- <?xml version="1.0" encoding="UTF-8"?>
- <root>
- <child foo="bar">
- <grandchild baz="fizbuzz">grandchild content</grandchild>
- </child>
- <sibling>with content!</sibling>
- </root>
-
-The other way is through chaining (indentation is meant to represent location in the tree):
-
- var doc = new libxml.Document();
- doc.node('root')
- .node('child', {foo: 'bar'})
- .node('grandchild', {baz: 'fizbuzz'}, 'grandchild content')
- .parent()
- .parent()
- .node('sibling', 'with content!');
-
-This will yield the same results.
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+ <child foo="bar">
+ <grandchild baz="fizbuzz">grandchild content</grandchild>
+ </child>
+ <sibling>with content!</sibling>
+</root>
+```
### Parsing
-By file:
+```javascript
+var doc = libxml.parseXmlString([xmlString]);
+```
- var doc = libxml.parseXmlFile([filename]);
-
-By String:
+#### SAX Parsing
- var doc = libxml.parseXml([xmlString]);
+SAX parsing objects are event emitters and callbacks can be connected in typical node.js fashion.
-#### SAX Parsing
+```javascript
+var parser = new libxml.SaxParser();
-Callbacks for SAX are created during the instantiation of the parser object. You can omit any callback you're not interested in. Below is just a list of callbacks currently supported with the arguments they'll be sent.
+parser.on('startDocument', ...);
+parser.on('startElement', ...);
+```
- var parser = new libxml.SaxParser(function(cb) {
- cb.onStartDocument(function() {});
- cb.onEndDocument(function() {});
- cb.onStartElementNS(function(elem, attrs, prefix, uri, namespaces) {});
- cb.onEndElementNS(function(elem, prefix, uri) {});
- cb.onCharacters(function(chars) {});
- cb.onCdata(function(cdata) {});
- cb.onComment(function(msg) {});
- cb.onWarning(function(msg) {});
- cb.onError(function(msg) {});
- });
+There is also a shorthand syntax for adding event callbacks during parser creation.
- // Parse a string:
- parser.parseString([xmlString]);
+```javascript
+var parser = new libxml.SaxParser({
+ startDocument: function() {...},
+ endDocument: function() {...},
+ startElementNS: function(elem, attrs, prefix, uri, namespaces) {...},
+});
- // Parse a file:
- parser.parseFile([filename]);
+// parse a string
+parser.parseString([xmlString]);
+```
#### SAX Push Parsing
Push parsers are created the same way DOM parsers are, but take input a chunk at a time:
- var parser = new libxml.SaxPushParser(function(cb) {
- cb.onStartDocument(function() {});
- cb.onEndDocument(function() {});
- cb.onStartElementNS(function(elem, attrs, prefix, uri, namespaces) {});
- cb.onEndElementNS(function(elem, prefix, uri) {});
- cb.onCharacters(function(chars) {});
- cb.onCdata(function(cdata) {});
- cb.onComment(function(msg) {});
- cb.onWarning(function(msg) {});
- cb.onError(function(msg) {});
- });
-
- while(xmlChunk)
- parser.push(xmlChunk);
-
-[Here's a more complex example](https://gist.github.com/484083)
-
-
-## Basics
-
-* GitHub Repo - [http://github.com/polotek/libxmljs](http://github.com/polotek/libxmljs)
-* Docs - [http://github.com/polotek/libxmljs/wiki](http://github.com/polotek/libxmljs/wiki)
-* Mailing list - [http://groups.google.com/group/libxmljs](http://groups.google.com/group/libxmljs)
-
-## Requirements
-
-* [libxml2](http://www.xmlsoft.org/)
-* [node.js](http://nodejs.org/)
-* v8 (comes bundled with node, no need to install)
-* [scons](http://www.scons.org/) (for building)
-
-**pre-conditions**
-
-You will need have the libxml2 library installed and also the libxml2-devel
-package. This comes with the `xml2-config` utility that is needed for
-compiling. **This command must be in your path.**
-
-The `scons` command is used for building and must also be in your path.
-
-## Installation
-
-To build the addon, the libxml C library must be installed and the xml2-config helper script must be on your path.
-
-**npm**
- npm install libxmljs
-
-**source**
-
-In the root of the source directory, just run `make`. This will
-generate the binary `libxmljs.node` in the root of the source folder.
-You can copy this file to `~/.node_libraries` or any other directory
-in your require path.
+```javascript
+var parser = new libxml.SaxPushParser();
-**tests**
+// connect any callbacks here
- make test
-
- make test-verbose
+while(xmlChunk) {
+ parser.push(xmlChunk);
+}
+```
58 docs/Migrating-from-0.4.x-to-0.5.0.md
View
@@ -0,0 +1,58 @@
+This page lists the API changes that occurred between the 0.4.x release and the 0.5.0 release. If you find that something was missed, please add it below.
+
+## Node Creation
+Node creation no longer takes a callback. This was changed to not give the appearance that the function is async. It returns immediately. This also simplifies code as you don't need to keep creating functions to use the new nodes.
+
+Where you would previously do:
+
+ doc.node('root', function(node) {
+ node.node('child', function(child) {
+ });
+ });
+
+You should now do:
+
+ var root = doc.node('root');
+ var child = root.node('child');
+
+## Attributes
+The attribute constructor no longer exists. To create an attribute just call the 'attr' method on a node. The constructor method was more verbose and error prone.
+
+Old way
+
+ var a = new libxmljs.Attribute(node, attr_name, attr_value);
+
+New Way
+
+ node.attr(attr_name, attr_value);
+
+You can also pass an object to attr of key-value pairs to set multiple attributes.
+
+## Sax Parsers
+
+Sax parser is an event emitter. You can connect to all of the events after creating a sax parser using the typical event emitter api.
+
+You can now do:
+
+ var parser = new SaxPushParser();
+ parser.on('startDocument', function() ... );
+
+Sax parser constructor no longer takes a function to configure but instead an object which lists the callbacks.
+
+Before you would do:
+
+ var parser = new SaxPushParser(function(cb) {
+ cb.onStartDocument(function() ... );
+ });
+
+You should now do (or better use the event emitter interface, see above):
+
+ var parser = new SaxPushParser({
+ startDocument: function() ...
+ });
+
+Or you can use the parser as an event emitter as described previously.
+
+## Removed API
+
+_parseHtmlFile_ and _parseXmlFile_ have been removed. Likewise, _SaxParser.parseFile_ has also been removed. If you want to read a file, use the nodejs file module instead.
1  docs/_Sidebar.md
View
@@ -4,7 +4,6 @@
* [[Attribute]]
* [[Namespace]]
* [[HtmlDocument]]
-* [[Parser]]
* [[SaxParser]]
* [[SaxPushParser]]
* [[SyntaxError]]
128 docs/api/Element.md
View
@@ -6,43 +6,14 @@ The Element class represents an element node in the XML tree.
## Constructor
-### new libxml.Element(doc, name)
-> Creates a new element object called name
+### new libxml.Element(doc, name, [content])
-> **args**
-*doc* - a Document object to provide context for the node
-*name* - a string representing the name of the element
+>Creates a new element object called name with attrs as its attributes. It is recommended that you use the *node* method of Document or Element instead.
-### new libxml.Element(doc, name, attrs)
-
->Creates a new element object called name with attrs as its attributes
-
->**args**
-*doc* - a document object to provide context for the node
-*name* - a string representing the name of the element
-*attrs* - a hash of {name: value} pairs to set as attributes
-
-### new libxml.Element(doc, name, attrs, content)
-
->Creates a new element object called name with attrs as its attributes
-
->**args**
-*doc* - a document object to provide context for the node
-*name* - a string representing the name of the element
-*attrs* - a hash of {name: value} pairs to set as attributes
-*content* - a string representing the content to add to the node
-*callback* - a function that will accept the new object as an argument
-
-### new libxml.Element(doc, name, attrs, content, callback)
-
->Creates a new element object called name with attrs as its attributes
-
->**args**
-*doc* - a document object to provide context for the node
-*name* - a string representing the name of the element
-*attrs* - a hash of {name: value} pairs to set as attributes
-*content* - a string representing the content to add to the node
-*callback* - a function that will accept the new object as an argument
+>**args**
+*doc* - a document object to provide context for the node
+*name* - a string representing the name of the element
+*content* - a string representing the content to add to the node
## Methods
@@ -57,7 +28,7 @@ The Element class represents an element node in the XML tree.
>Set the name of the element
->**args**
+>**args**
*new_name* - a string representing the new name of the element
>**returns** - the Element object
@@ -75,8 +46,8 @@ The Element class represents an element node in the XML tree.
>Get the Attribute called name
->**args**
-*name* - a string representing the name of the attribute
+>**args**
+*name* - a string representing the name of the attribute
>**returns** - an Attribute node or null
@@ -85,8 +56,8 @@ The Element class represents an element node in the XML tree.
>Add an Attribute object to the element
->**args**
-*attr* - an Attribute node
+>**args**
+*attr* - an Attribute node
>**returns** - the element node (not the attribute)
@@ -95,8 +66,8 @@ The Element class represents an element node in the XML tree.
>Create a set of attributes from a hash and add them to the element
->**args**
-*attr* - an object of {name: value} pairs
+>**args**
+*attr* - an object of {name: value} pairs
>**returns** - the element object
@@ -126,13 +97,13 @@ The Element class represents an element node in the XML tree.
>Get a child node by index
->**args**
-*idx* - a zero indexed integer representing the child node to return
+>**args**
+*idx* - a zero indexed integer representing the child node to return
>**returns** - a Node object or null
-### elements.childNodes()
+### element.childNodes()
>Get a list of all the immediate children of the element
@@ -143,8 +114,8 @@ The Element class represents an element node in the XML tree.
>Add a child node to the node
->**args**
-*child* - an Element node to be added as a child
+>**args**
+*child* - an Element node to be added as a child
>**returns** - the element node (not the child)
@@ -167,7 +138,7 @@ The Element class represents an element node in the XML tree.
>Add a Node as a sibling immediately after this element
->**args**
+>**args**
*siblingNode* - a Node to add as a sibling
>**returns** - the sibling object
@@ -191,7 +162,7 @@ The Element class represents an element node in the XML tree.
>Add a Node as a sibling immediately before this element
->**args**
+>**args**
*siblingNode* - a Node to add as a sibling
>**returns** - the sibling object
@@ -201,8 +172,8 @@ The Element class represents an element node in the XML tree.
>Search the element's children by xpath
->**args**
-*xpath* - a string representing the xpath to search
+>**args**
+*xpath* - a string representing the xpath to search
>**returns** - an array of Node objects. may be empty
@@ -211,47 +182,48 @@ The Element class represents an element node in the XML tree.
>Search the element's children by xpath within the URI namespace
->**args**
-*xpath* - a string representing the xpath to search
-*ns_uri* - a string representing the namespace URI
+>**args**
+*xpath* - a string representing the xpath to search
+*ns_uri* - a string representing the namespace URI
>**returns** - an array of Node objects
-*example*
- doc.find("xmlns:child-name", "ns:uri")
+*examples*
+ `doc.find("xmlns:child-name", "ns:uri")
+ doc.find('//y:child-name', { y: 'http://some.com/for/y'});`
### element.get(xpath, ns_uri)
->Return the first node node that matches the xpath expression
+>Return the first node node that matches the xpath expression
This this is syntactic sugar for `find(xpath, ns_uri)[0]`
->**args**
-*xpath* - a string representing the xpath to search
-*ns_uri* - a string representing the namespace URI
+>**args**
+*xpath* - a string representing the xpath to search
+*ns_uri* - a string representing the namespace URI
>**returns** - a Node or null
### element.find(xpath, namespaces)
->Search the element's children by xpath within any of the URI
+>Search the element's children by xpath within any of the URI
namespaces
->**args**
-*xpath* - a string representing the xpath to search
-*namespaces* - a hash representing the namespaces
+>**args**
+*xpath* - a string representing the xpath to search
+*namespaces* - a hash representing the namespaces
>**returns** - an array of Node objects
-*example*
+*example*
doc.find("ns-1:child-name", {"ns-1": "ns:uri"})
doc.find("ns-1:child1/ns-2:child2", {"ns-1": "ns:uri1", "ns-2": "ns:uri2"})
### element.get(xpath, ns_uri)
->Return the first node that matches the xpath
+>Return the first node that matches the xpath
This is syntactic sugar for `find(xpath, namespaces)[0]`
>**returns** - a element object or null
@@ -262,8 +234,8 @@ This is syntactic sugar for `find(xpath, namespaces)[0]`
>Define a new namespace on the element using href for the URI. This
will only define the namespace but wont add it to the node
->**args**
-*href* - a string representing the URI of the new namespace
+>**args**
+*href* - a string representing the URI of the new namespace
>**returns** - the new Namespace object
@@ -274,9 +246,9 @@ will only define the namespace but wont add it to the node
prefix as the prefix. This will only define the namespace but wont add
it to the node
->**args**
-*prefix* - a string representing the prefix for the new namespace
-*href* - a string representing the URI for the new namespace
+>**args**
+*prefix* - a string representing the prefix for the new namespace
+*href* - a string representing the URI for the new namespace
>**returns** - the new Namespace object
@@ -292,8 +264,8 @@ Get the elements's namespace
>Set the element's namespace to ns
->**args**
-*ns* - a Namespace object
+>**args**
+*ns* - a Namespace object
>**returns** - the element object
@@ -304,8 +276,8 @@ Get the elements's namespace
up the tree to find a namespace with the given href and, if found will
use it. Otherwise it will create a new namespace.
->**args**
-*href* - a string representing the namespace URI
+>**args**
+*href* - a string representing the namespace URI
>**returns** - the namespace object
@@ -317,9 +289,9 @@ node. This will search up the tree to find a namespace with the given
href and, if found will use it. Otherwise it will create a new
namespace.
->**args**
-*prefix* - a string representing the namespace prefix
-*href* - a string representing the namespace URI
+>**args**
+*prefix* - a string representing the namespace prefix
+*href* - a string representing the namespace URI
>**returns** - the Namespace object
14 docs/api/Libxmljs.md
View
@@ -22,3 +22,17 @@ The module export object that comes from `require('libxmljs')`
>Get the loaded version of libxml
>**returns** a string
+
+### Functions
+
+**parseXmlString(string)**
+
+>Parse the string as xml and return a Document object. Throws if there was an error parsing
+
+>**returns** a Document
+
+**parseHtmlString(string)**
+
+>Parse the string as html and return a Document object. Throws if there was an error parsing
+
+>**returns** a Document
48 docs/api/Parser.md
View
@@ -1,48 +0,0 @@
-# Parser
-
-A document can be parsed as a string or a file. Once parsed an object holding
-the document as a set of javascript objects is returned
-
-### Methods
-
-
-#### libxmljs.parseXml(string)
-
->Parse an in-memory XML string
-
->**args**
-*string* - a string representing the document to parse
-
-
->**returns** an XmlDocument object
-
-#### libxmljs.parseXmlFile(filename)
-
->Parse an XML file
-
->**args**
-*filename* - a string representing the filename of the document
-
-
->**returns** an XmlDocument object
-
-#### libxmljs.parseHtml(string)
-
->Parse an in-memory HTML string
-
->**args**
-*string* - a string representing the document to parse
-
-
->**returns** an HtmlDocument object
-
-#### libxmljs.parseHtmlFile(filename)
-
->Parse an HTML file
-
->**args**
-*filename* - a string representing the filename of the document
-
-
->**returns** an HtmlDocument object
-
77 docs/api/SaxParser.md
View
@@ -1,43 +1,13 @@
# SaxParser
-libxmljs provides a SAX2 parser interface that can take a string, file.
+libxmljs provides a SAX2 parser interface that can take a string, file. A SaxParser inherits from EventEmitter to emit parsing events.
### Constructor
-
#### new libxml.SaxParser()
>Instantiate a new SaxParser
-#### new libxml.SaxParser(callbacks)
-
->Instantiate a new SaxParser
-
->**args**
-*callbacks* - an object with event names as properties and event handler functions as values
-
-
-### Parse Events
-
->**startDocument** - Fired at the start of a document
-
->**endDocument** - Fired at the end of the document parse
-
->**startElementNS** - Fired on an open element tag
-
->**endElementNS** - Fired at the close of an element
-
->**characters** - Fired when a set of content characters is encountered
-
->**cdata** - Fired when a CDATA is encountered
-
->**comment** - Fired when an comment is encountered
-
->**warning** - Fired when an warning is encountered
-
->**error** - Fired when an error is encountered
-
-
### Methods
#### parser.parseString(string)
@@ -48,17 +18,19 @@ libxmljs provides a SAX2 parser interface that can take a string, file.
>**args**
*string* - a string representing the document to parse
-#### parser.onStartDocument(function() {})
+### Parse Events
+
+#### startDocument
->Called at the start of a document
+>Emitted at the start of a document
-#### parse.onEndDocument(function() {})
+#### endDocument
->Called at the end of the document parse
+>Emitted at the end of the document parse
-#### parser.onStartElementNS(function(elem, attrs, prefix, uri, namespaces) {})
+#### startElementNS(elem, attrs, prefix, uri, namespace)
->Called on an open element tag
+>Emitted on an open element tag
>**args**
*elem* - a string representing the element name
@@ -67,54 +39,47 @@ libxmljs provides a SAX2 parser interface that can take a string, file.
*uri* - the namespace URI of the element
*namespaces* - an array of arrays: `[[prefix, uri]]`
+#### endElementNS(elem, prefix, uri)
-#### parser.onEndElementNS(function(elem, prefix, uri) {})
-
->Called at the close of an element
+>Emitted at the close of an element
>**args**
*elem* - a string representing the element name
*prefix* - a string representing the namespace prefix of the element
*uri* - the namespace URI of the element
+#### characters(chars)
-#### parser.onCharacters(function(chars) {})
-
->Called when a set of content characters is encountered
+>Emitted when a set of content characters is encountered
>**args**
*chars* - a string of characters
+#### cdata(cdata)
-#### parser.onCdata(function(cdata) {})
-
->Called when a CDATA is encountered
+>Emitted when a CDATA is encountered
>**args**
*cdata* - a string representing the CDATA
+#### comment(msg)
-#### parser.onComment(function(msg) {})
-
->Called when a comment is encountered
+>Emitted when a comment is encountered
>**args**
*msg* - a string representing the comment
+#### warning(msg)
-#### parser.onWarning(function(msg) {})
-
->Called when a warning is encountered
+>Emitted when a warning is encountered
>**args**
*msg* - a string representing the warning message
+#### error(msg)
-#### parser.onError(function(msg) {})
-
->Called when an error is encountered
+>Emitted when an error is encountered
>**args**
*msg* - a string representing the error message
-
81 docs/api/SaxPushParser.md
View
@@ -1,45 +1,15 @@
# SaxPushParser
-libxmljs provides a SAX2 push parser interface that accepts chunks of data.
+libxmljs provides a SAX2 push parser interface that accepts chunks of data. SaxPush parser inherits from EventEmitter to emit parse events.
### Constructor
-
#### new libxmljs.SaxPushParser()
>Instantiate a new SaxParser
-#### new libxmljs.SaxPushParser(callbacks)
-
->Instantiate a new SaxParser
-
->**args**
-*callbacks* - an object with event names as properties and event handler functions as values
-
-### Parse Events
-
->**startDocument** - Fired at the start of a document
-
->**endDocument** - Fired at the end of the document parse
-
->**startElementNS** - Fired on an open element tag
-
->**endElementNS** - Fired at the close of an element
-
->**characters** - Fired when a set of content characters is encountered
-
->**cdata** - Fired when a CDATA is encountered
-
->**comment** - Fired when an comment is encountered
-
->**warning** - Fired when an warning is encountered
-
->**error** - Fired when an error is encountered
-
-
### Methods
-
#### parser.push(string)
>Push a chunk of data into the parserreturn: boolean. true if no errors, false otherwise
@@ -47,18 +17,19 @@ libxmljs provides a SAX2 push parser interface that accepts chunks of data.
>**args**
*string* - a string representing the document to parse
+### Parse Events
-#### parser.onStartDocument(function() {})
+#### startDocument
->Called at the start of a document
+>Emitted at the start of a document
-#### parse.onEndDocument(function() {})
+#### endDocument
->Called at the end of the document parse
+>Emitted at the end of the document parse
-#### parser.onStartElementNS(function(elem, attrs, prefix, uri, namespaces) {})
+#### startElementNS(elem, attrs, prefix, uri, namespace)
->Called on an open element tag
+>Emitted on an open element tag
>**args**
*elem* - a string representing the element name
@@ -67,59 +38,47 @@ libxmljs provides a SAX2 push parser interface that accepts chunks of data.
*uri* - the namespace URI of the element
*namespaces* - an array of arrays: `[[prefix, uri]]`
+#### endElementNS(elem, prefix, uri)
-#### parser.onEndElementNS(function(elem, prefix, uri) {})
-
->Called at the close of an element
+>Emitted at the close of an element
>**args**
*elem* - a string representing the element name
*prefix* - a string representing the namespace prefix of the element
*uri* - the namespace URI of the element
+#### characters(chars)
-#### parser.onCharacters(function(chars) {})
-
->Called when a set of content characters is encountered
+>Emitted when a set of content characters is encountered
>**args**
*chars* - a string of characters
+#### cdata(cdata)
-#### parser.onCdata(function(cdata) {})
-
->Called when a CDATA is encountered
+>Emitted when a CDATA is encountered
>**args**
*cdata* - a string representing the CDATA
+#### comment(msg)
-#### parser.onComment(function(msg) {})
-
->Called when a comment is encountered
+>Emitted when a comment is encountered
>**args**
*msg* - a string representing the comment
+#### warning(msg)
-#### parser.onWarning(function(msg) {})
-
->Called when a warning is encountered
+>Emitted when a warning is encountered
>**args**
*msg* - a string representing the warning message
+#### error(msg)
-#### parser.onError(function(msg) {})
-
->Called when an error is encountered
+>Emitted when an error is encountered
>**args**
*msg* - a string representing the error message
-
-### Examples
-
-Here's an extended example of using the sax push parser to recreate an xml document.
-
-[http://gist.github.com/484083](http://gist.github.com/484083)
74 docs/api/XmlDocument.md
View
@@ -5,69 +5,14 @@ instantiating an object using the "new" keyword or by parsing a document.
## Constructor
-
-### new libxmljs.Document();
-
->Instantiate a new document object defaulting the version to 1.0 and the
-encoding to UTF-8.
-
->**returns** a new document object
-
-### new libxmljs.Document(callback);
-
->Instantiate a new document object defaulting the version to 1.0 and the
-encoding to UTF-8.
-
->**args**
-*callback* - a function that accepts the new document object
-
-
->**returns** a new document object
-
-### new libxmljs.Document(version);
-
->Instantiate a new document setting the version to version and defaulting
-the encoding to UTF-8.
-
->**args**
-*version* - a string representing the desired document version
-
-
->**returns** a new document object
-
-### new libxmljs.Document(version, callback);
-
->Instantiate a new document setting the version to version and defaulting
-the encoding to UTF-8.
-
->**args**
-*version* - a string representing the desired document version
-*callback* - a function that accepts the new document object
-
-
->**returns** a new document object
-
### new libxmljs.Document(version, encoding);
>Instantiate a new document setting the version to version and the encoding
to encoding.
>**args**
-*version* - a string representing the desired document version
-*encoding* - a string representing the desired document encoding
-
-
->**returns** a new document object
-
-### new libxmljs.Document(version, encoding, callback);
-
->Instantiate a new document setting the version to version and the encoding
-to encoding.
-
->**args**
-*version* - a string representing the desired document version
-*encoding* - a string representing the desired document encoding
-*callback* - a function that accepts the new document as an argument
+*version* - a string representing the desired document version (default '1.0')
+*encoding* - a string representing the desired document encoding (default 'utf8')
>**returns** a new document object
@@ -92,12 +37,6 @@ See Element#child for more information
>**returns** an array of element objects
-### doc.document()
-
->A convenience method that
-
->**returns** the document object
-
### doc.errors()
>An array of recoverable errors encountered while parsing the document
@@ -139,10 +78,15 @@ See Element#get for more information
>**returns** a element object or null
-### doc.node([args])
+### doc.node(name, content)
>A convenience method for creating and setting the root node
-See new libxmljs.Element for the full spec
+
+>**args**
+*name* - the tag name
+*content* - text content of the node (a string)
+
+>**returns** the newly created node
### doc.root()
Please sign in to comment.
Something went wrong with that request. Please try again.