DOMDocument
class DOMDocument extends DOMNode implements DOMParentNode (View source)
The DOMDocument class represents an entire HTML or XML document; serves as the root of the document tree.
Constants
DOCUMENT_POSITION_DISCONNECTED
Since: 8.4
|
|
DOCUMENT_POSITION_PRECEDING
Since: 8.4
|
|
DOCUMENT_POSITION_FOLLOWING
Since: 8.4
|
|
DOCUMENT_POSITION_CONTAINS
Since: 8.4
|
|
DOCUMENT_POSITION_CONTAINED_BY
Since: 8.4
|
|
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
Since: 8.4
|
|
Properties
string | $nodeName | from DOMNode | |
string|null | $nodeValue | from DOMNode | |
int | $nodeType | from DOMNode | |
DOMNode|null | $parentNode | from DOMNode | |
DOMNode> | $childNodes | from DOMNode | |
DOMNode|null | $firstChild | from DOMNode | |
DOMNode|null | $lastChild | from DOMNode | |
DOMNode|null | $previousSibling | from DOMNode | |
DOMNode|null | $nextSibling | from DOMNode | |
DOMAttr>|null | $attributes | from DOMNode | |
DOMDocument|null | $ownerDocument | from DOMNode | |
string|null | $namespaceURI | from DOMNode | |
string|null | $prefix | from DOMNode | |
string|null | $localName | from DOMNode | |
string|null | $baseURI | from DOMNode | |
string | $textContent | from DOMNode | |
bool | $isConnected | from DOMNode | |
DOMElement|null | $parentElement | from DOMNode | |
string|null | $actualEncoding | ||
DOMConfiguration | $config | ||
DOMDocumentType | $doctype | ||
DOMElement | $documentElement | ||
string|null | $documentURI | ||
string|null | $encoding | ||
bool | $formatOutput | ||
DOMImplementation | $implementation | ||
bool | $preserveWhiteSpace | ||
bool | $recover | ||
bool | $resolveExternals | ||
bool | $standalone | ||
bool | $strictErrorChecking | ||
bool | $substituteEntities | ||
bool | $validateOnParse | ||
string | $version | ||
string|null | $xmlEncoding | ||
bool | $xmlStandalone | ||
string|null | $xmlVersion | ||
$childElementCount | |||
$lastElementChild | |||
$firstElementChild |
Methods
Checks if feature is supported for specified version
Gets the namespace prefix of the node based on the namespace URI
Checks if the specified namespaceURI is the default namespace or not
Gets the namespace URI of the node based on the prefix
Gets the namespace URI of the node based on the prefix
Canonicalize nodes to a string
Canonicalize nodes to a file.
Create new element node
Create new document fragment
Create new text node
Create new comment node
Create new cdata node
Creates new PI node
Create new attribute
Create new entity reference node
Searches for all elements with given tag name
Create new element node with an associated namespace
Create new attribute node with an associated namespace
Searches for all elements with given tag name in specified namespace
Searches for an element with a certain id
No description
Normalizes the document
Load XML from a file
Dumps the internal XML tree back into a file
Load XML from a string
Creates a new DOMDocument object
Validates the document based on its DTD
Substitutes XIncludes in a DOMDocument Object
Load HTML from a string
Load HTML from a file
Dumps the internal document into a file using HTML formatting
Validates a document based on a schema
Validates a document based on a schema
Performs relaxNG validation on the document
Performs relaxNG validation on the document
Register extended class used to create base node type
Details
DOMNode
insertBefore(DOMNode $node, null|DOMNode $child = null)
Adds a new child before a reference node
bool
hasChildNodes()
Checks if node has children
DOMNode
cloneNode(bool $deep = false)
Clones a node
void
normalize()
Normalizes the node
bool
isSupported(string $feature, string $version)
Checks if feature is supported for specified version
bool
hasAttributes()
Checks if node has attributes
int
compareDocumentPosition(DOMNode $other)
No description
bool
isSameNode(DOMNode $otherNode)
Indicates if two nodes are the same node
string|null
lookupPrefix(string $namespace)
Gets the namespace prefix of the node based on the namespace URI
bool
isDefaultNamespace(string $namespace)
Checks if the specified namespaceURI is the default namespace or not
string|null
lookupNamespaceURI(string|null $prefix)
Gets the namespace URI of the node based on the prefix
string|null
lookupNamespaceUri(string|null $prefix)
Gets the namespace URI of the node based on the prefix
bool
isEqualNode($otherNode)
No description
getFeature($feature, $version)
No description
setUserData($key, $data, $handler)
No description
getUserData($key)
No description
string|null
getNodePath()
Gets an XPath location path for the node
int
getLineNo()
Get line number for a node
string|false
C14N(bool $exclusive = false, bool $withComments = false, null|array $xpath = null, null|array $nsPrefixes = null)
Canonicalize nodes to a string
int|false
C14NFile(string $uri, bool $exclusive = false, bool $withComments = false, null|array $xpath = null, null|array $nsPrefixes = null)
Canonicalize nodes to a file.
bool
contains(DOMNode|DOMNameSpaceNode|null $other)
No description
DOMNode
getRootNode(array|null $options = null)
No description
array
__sleep()
No description
void
__wakeup()
No description
DOMElement|false
createElement(string $localName, string $value = '')
Create new element node
DOMDocumentFragment
createDocumentFragment()
Create new document fragment
DOMText
createTextNode(string $data)
Create new text node
DOMComment
createComment(string $data)
Create new comment node
DOMCDATASection|false
createCDATASection(string $data)
Create new cdata node
DOMProcessingInstruction|false
createProcessingInstruction(string $target, string $data = '')
Creates new PI node
DOMAttr|false
createAttribute(string $localName)
Create new attribute
DOMEntityReference|false
createEntityReference(string $name)
Create new entity reference node
DOMNodeList
getElementsByTagName(string $qualifiedName)
Searches for all elements with given tag name
DOMElement|false
createElementNS(string|null $namespace, string $qualifiedName, string $value = '')
Create new element node with an associated namespace
DOMAttr|false
createAttributeNS(string|null $namespace, string $qualifiedName)
Create new attribute node with an associated namespace
DOMNodeList
getElementsByTagNameNS(string $namespace, string $localName)
Searches for all elements with given tag name in specified namespace
DOMElement|null
getElementById(string $elementId)
Searches for an element with a certain id
adoptNode(DOMNode $node)
No description
void
append(DOMNode|string|null ...$nodes)
Appends one or many nodes to the list of children behind the last child node.
void
prepend(DOMNode|string|null ...$nodes)
Prepends one or many nodes to the list of children before the first child node.
void
replaceChildren(...$nodes)
No description
void
normalizeDocument()
Normalizes the document
renameNode(DOMNode $node, $namespace, $qualifiedName)
No description
DOMDocument|bool
load(string $filename, int $options = 0)
Load XML from a file
int|false
save(string $filename, int $options = null)
Dumps the internal XML tree back into a file
DOMDocument|bool
loadXML(string $source, int $options = 0)
Load XML from a string
string|false
saveXML(null|DOMNode $node = null, int $options = 0)
Dumps the internal XML tree back into a string
__construct(string $version = '1.0', string $encoding = '')
Creates a new DOMDocument object
bool
validate()
Validates the document based on its DTD
int|false
xinclude(int $options = 0)
Substitutes XIncludes in a DOMDocument Object
DOMDocument|bool
loadHTML(string $source, int $options = 0)
Load HTML from a string
DOMDocument|bool
loadHTMLFile(string $filename, int $options = 0)
Load HTML from a file
string|false
saveHTML(DOMNode $node = null)
Dumps the internal document into a string using HTML formatting
int|false
saveHTMLFile(string $filename)
Dumps the internal document into a file using HTML formatting
bool
schemaValidate(string $filename, int $options = null)
Validates a document based on a schema
bool
schemaValidateSource(string $source, int $flags)
Validates a document based on a schema
bool
relaxNGValidate(string $filename)
Performs relaxNG validation on the document
bool
relaxNGValidateSource(string $source)
Performs relaxNG validation on the document
bool
registerNodeClass(string $baseClass, string $extendedClass)
Register extended class used to create base node type