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.
number
Describe the
Document
as an XML document.value
0
number
Describe the
Document
as an HTML document.value
1
number
Describe the
Document
as an HTML fragment.value
2
libxmljs.Document|null
The internal
libxmljs.Document
instance.
boolean
Tells whether the
Document
has content.
object|null
The object that holds the namespace information.
SyntaxError[]
An array containing the errors in the current
Document
.
ValidationError[]|undefined
An array containing the validation errors in the current
Document
.
libxmljs.Element|null
Gets the idxth child of the root node.
args
idx:number
- The child index.returns A
libxmljs.Element
ornull
.
libxmljs.Element[]
Gets all the children of the root node.
returns An array of
libxmljs.Element
s.
number
Counts the amount of results of the provided XPath.
args
xpath:string
- The XPath to count.returns The amount of results.
string
Gets the
Document
's encoding.returns The
Document
's encoding.
Document
Sets 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.Element
s.
Document
Parses an HTML document.
args
html:string
- The HTML content.
options:libxmljs.ParserOptions
(optional) - The parser options.returns The
Document
.
Document
Parses an HTML fragment.
args
htmlFragment:string
- The HTML content.
options:libxmljs.ParserOptions
(optional) - The parser options.returns The
Document
.
Document
Parses an XML document.
args
xml:string
- The XML content.
options:libxmljs.ParserOptions
(optional) - The parser options.returns The
Document
.
libxmljs.Element
Gets the first result of the provided XPath.
args
xpath:string
- The XPath to get.returns A
libxmljs.Element
.
object
Gets the
Document
's DTD.returns The DTD object.
libxmljs.Namespace[]
Gets the
Document
's namespaces.returns An array of
libxmljs.Namespace
s.
libxmljs.Node
Creates the root.
args
name:string
- The root's tag name.
content:string
- The root's text content.returns The created
libxmljs.Node
.
boolean
Checks whether the
Document
is valid using Relax NG.args
rng:object
- The Relax NG.returns Whether the
Document
is valid using Relax NG.
libxmljs.Element|null
Gets the root.
returns The root or
null
.
libxmljs.Element
Sets the root.
args
node:libxmljs.Element
- The rootlibxmljs.Element
.returns The created
libxmljs.Element
.
Document
Sets 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
.
Document
Sets the
Document
's namespace.args
alias:string
- The alias of the namespace.
url:string
- The URL of the namespace.returns The
Document
.
string
Returns the
Document
as a string.args
formatting:boolean
(optional) - Tells whether the ouput is formatted.returns The
Document
as a string.
string
Returns the string "document".
returns "document".
boolean
Validates the
Document
against a XSD document.args
xsdDoc:Document
- The XSDDocument
.returns Whether the
Document
is valid.validationErrors
contains the errors if any.
string
Gets the
Document
's version.returns The
Document
's version.
void
Throws an error if the
Document
has no content.