A copy of the Document class from libxmljs with extra methods and existing ones modified.
Creates a new
Document.args
source:string(optional) - The source as a string.
type:number(optional) - The type of theDocument.
options:libxmls.ParserOptions(optional) - The parser options.
numberDescribe the
Documentas an XML document.value
0
numberDescribe the
Documentas an HTML document.value
1
numberDescribe the
Documentas an HTML fragment.value
2
libxmljs.Document|nullThe internal
libxmljs.Documentinstance.
booleanTells whether the
Documenthas content.
object|nullThe object that holds the namespace information.
SyntaxError[]An array containing the errors in the current
Document.
ValidationError[]|undefinedAn array containing the validation errors in the current
Document.
libxmljs.Element|nullGets the idxth child of the root node.
args
idx:number- The child index.returns A
libxmljs.Elementornull.
libxmljs.Element[]Gets all the children of the root node.
returns An array of
libxmljs.Elements.
numberCounts the amount of results of the provided XPath.
args
xpath:string- The XPath to count.returns The amount of results.
stringGets the
Document's encoding.returns The
Document's encoding.
DocumentSets the
Document's encoding.args
enc:string- The encoding as a string.returns The
Document.
libxmljs.Element[]Finds the result of the provided XPath.
args
xpath:string- The XPath to find.returns An array of
libxmljs.Elements.
DocumentParses an HTML document.
args
html:string- The HTML content.
options:libxmljs.ParserOptions(optional) - The parser options.returns The
Document.
DocumentParses an HTML fragment.
args
htmlFragment:string- The HTML content.
options:libxmljs.ParserOptions(optional) - The parser options.returns The
Document.
DocumentParses an XML document.
args
xml:string- The XML content.
options:libxmljs.ParserOptions(optional) - The parser options.returns The
Document.
libxmljs.ElementGets the first result of the provided XPath.
args
xpath:string- The XPath to get.returns A
libxmljs.Element.
objectGets the
Document's DTD.returns The DTD object.
libxmljs.Namespace[]Gets the
Document's namespaces.returns An array of
libxmljs.Namespaces.
libxmljs.NodeCreates the root.
args
name:string- The root's tag name.
content:string- The root's text content.returns The created
libxmljs.Node.
booleanChecks whether the
Documentis valid using Relax NG.args
rng:object- The Relax NG.returns Whether the
Documentis valid using Relax NG.
libxmljs.Element|nullGets the root.
returns The root or
null.
libxmljs.ElementSets the root.
args
node:libxmljs.Element- The rootlibxmljs.Element.returns The created
libxmljs.Element.
DocumentSets the
Document's DTD.args
name:string- The name of the DTD.
ext:string- The external ID for the DTD.
sys:string- The system ID for the DTD.returns The
Document.
DocumentSets the
Document's namespace.args
alias:string- The alias of the namespace.
url:string- The URL of the namespace.returns The
Document.
stringReturns the
Documentas a string.args
formatting:boolean(optional) - Tells whether the ouput is formatted.returns The
Documentas a string.
stringReturns the string "document".
returns "document".
booleanValidates the
Documentagainst a XSD document.args
xsdDoc:Document- The XSDDocument.returns Whether the
Documentis valid.validationErrorscontains the errors if any.
stringGets the
Document's version.returns The
Document's version.
voidThrows an error if the
Documenthas no content.