DOM Reference

Reference for the classes exposed by PHP's DOM extension (php.net/manual/en/book.dom.php). All node types extend DOMNode.

DOMNode

readonly string $nodeName;
string $nodeValue;
readonly int $nodeType;
readonly DOMNode $parentNode;
readonly DOMNodeList $childNodes;
readonly DOMNode $firstChild;
readonly DOMNode $lastChild;
readonly DOMNode $previousSibling;
readonly DOMNode $nextSibling;
readonly DOMNamedNodeMap $attributes;
readonly DOMDocument $ownerDocument;
readonly string $namespaceURI;
string $prefix;
readonly string $localName;
readonly string $baseURI;
readonly string $textContent;
DOMNode appendChild(DOMNode $newnode)
string C14N([bool $exclusive [, bool $with_comments [, array $xpath [, array $ns_prefixes]]]])
int C14NFile(string $uri [, bool $exclusive [, bool $with_comments [, array $xpath [, array $ns_prefixes]]]])
DOMNode cloneNode([bool $deep])
int getLineNo(void)
string getNodePath(void)
bool hasAttributes(void)
bool hasChildNodes(void)
DOMNode insertBefore(DOMNode $newnode [, DOMNode $refnode])
bool isDefaultNamespace(string $namespaceURI)
bool isSameNode(DOMNode $node)
bool isSupported(string $feature, string $version)
string lookupNamespaceURI(string $prefix)
string lookupPrefix(string $namespaceURI)
void normalize(void)
DOMNode removeChild(DOMNode $oldnode)
DOMNode replaceChild(DOMNode $newnode, DOMNode $oldnode)

DOMDocument extends DOMNode

readonly string $actualEncoding;
readonly DOMConfiguration $config;
readonly DOMDocumentType $doctype;
readonly DOMElement $documentElement;
string $documentURI;
string $encoding;
bool $formatOutput;
readonly DOMImplementation $implementation;
bool $preserveWhiteSpace = true;
bool $recover;
bool $resolveExternals;
bool $standalone;
bool $strictErrorChecking = true;
bool $substituteEntities;
bool $validateOnParse = false;
string $version;
readonly string $xmlEncoding;
bool $xmlStandalone;
string $xmlVersion;
__construct([string $version [, string $encoding]])
DOMAttr createAttribute(string $name)
DOMAttr createAttributeNS(string $namespaceURI, string $qualifiedName)
DOMCDATASection createCDATASection(string $data)
DOMComment createComment(string $data)
DOMDocumentFragment createDocumentFragment(void)
DOMElement createElement(string $name [, string $value])
DOMElement createElementNS(string $namespaceURI, string $qualifiedName [, string $value])
DOMEntityReference createEntityReference(string $name)
DOMProcessingInstruction createProcessingInstruction(string $target [, string $data])
DOMText createTextNode(string $content)
DOMElement getElementById(string $elementId)
DOMNodeList getElementsByTagName(string $name)
DOMNodeList getElementsByTagNameNS(string $namespaceURI, string $localName)
DOMNode importNode(DOMNode $importedNode [, bool $deep])
mixed load(string $filename [, int $options = 0])
bool loadHTML(string $source [, int $options = 0])
bool loadHTMLFile(string $filename [, int $options = 0])
mixed loadXML(string $source [, int $options = 0])
void normalizeDocument(void)
bool registerNodeClass(string $baseclass, string $extendedclass)
bool relaxNGValidate(string $filename)
bool relaxNGValidateSource(string $source)
int save(string $filename [, int $options])
string saveHTML([DOMNode $node = NULL])
int saveHTMLFile(string $filename)
string saveXML([DOMNode $node [, int $options]])
bool schemaValidate(string $filename [, int $flags])
bool schemaValidateSource(string $source [, int $flags])
bool validate(void)
int xinclude([int $options])

For the save*() functions, only LIBXML_NOEMPTYTAG is a supported $options value. For the load*() functions and xinclude(), $options accepts any combination of the libxml constants: LIBXML_COMPACT, LIBXML_DTDATTR, LIBXML_DTDLOAD, LIBXML_DTDVALID, LIBXML_HTML_NOIMPLIED, LIBXML_HTML_NODEFDTD, LIBXML_NOBLANKS, LIBXML_NOCDATA, LIBXML_NOEMPTYTAG, LIBXML_NOENT, LIBXML_NOERROR, LIBXML_NONET, LIBXML_NOWARNING, LIBXML_NOXMLDECL, LIBXML_NSCLEAN, LIBXML_PARSEHUGE, LIBXML_PEDANTIC, LIBXML_XINCLUDE, LIBXML_ERR_ERROR, LIBXML_ERR_FATAL, LIBXML_ERR_NONE, LIBXML_ERR_WARNING, LIBXML_VERSION, LIBXML_DOTTED_VERSION, LIBXML_SCHEMA_CREATE. The methods loadXML(), loadHTML(), saveXML(), saveHTML(), relaxNGValidateSource(), and schemaValidateSource() operate on an in-memory string rather than a file.


DOMElement extends DOMNode

readonly bool $schemaTypeInfo;
readonly string $tagName;
__construct(string $name [, string $value [, string $namespaceURI]])
string getAttribute(string $name)
DOMAttr getAttributeNode(string $name)
DOMAttr getAttributeNodeNS(string $namespaceURI, string $localName)
string getAttributeNS(string $namespaceURI, string $localName)
DOMNodeList getElementsByTagName(string $name)
DOMNodeList getElementsByTagNameNS(string $namespaceURI, string $localName)
bool hasAttribute(string $name)
bool hasAttributeNS(string $namespaceURI, string $localName)
bool removeAttribute(string $name)
bool removeAttributeNode(DOMAttr $oldnode)
bool removeAttributeNS(string $namespaceURI, string $localName)
DOMAttr setAttribute(string $name, string $value)
DOMAttr setAttributeNode(DOMAttr $attr)
DOMAttr setAttributeNodeNS(DOMAttr $attr)
void setAttributeNS(string $namespaceURI, string $qualifiedName, string $value)
void setIdAttribute(string $name, bool $isId)
void setIdAttributeNode(DOMAttr $attr, bool $isId)
void setIdAttributeNS(string $namespaceURI, string $localName, bool $isId)

DOMAttr extends DOMNode

readonly string $name;
readonly DOMElement $ownerElement;
readonly bool $schemaTypeInfo;
readonly bool $specified;
string $value;
__construct(string $name [, string $value])
bool isId(void)

DOMDocumentFragment extends DOMNode

bool appendXML(string $data)

DOMDocumentType extends DOMNode

readonly string $Id; // publicId
readonly string $systemId;
readonly string $name;
readonly DOMNamedNodeMap $entities;
readonly DOMNamedNodeMap $notations;
readonly string $internalSubset;

DOMNotation extends DOMNode

readonly string $Id; // publicId
readonly string $systemId;

DOMEntity extends DOMNode

readonly string $Id; // publicId
readonly string $systemId;
readonly string $notationName;
string $actualEncoding;
readonly string $encoding;
readonly string $version;

DOMEntityReference extends DOMNode

__construct(string $name)

DOMProcessingInstruction extends DOMNode

readonly string $target;
string $data;
__construct(string $name [, string $value])

DOMCharacterData extends DOMNode

string $data;
readonly int $length;
void appendData(string $data)
void deleteData(int $offset, int $count)
void insertData(int $offset, string $data)
void replaceData(int $offset, int $count, string $data)
string substringData(int $offset, int $count)

DOMComment extends DOMCharacterData

__construct([string $value])

DOMText extends DOMCharacterData

readonly string $wholeText;
__construct([string $value])
bool isWhitespaceInElementContent(void)
DOMText splitText(int $offset)

DOMCdataSection extends DOMText

__construct(string $value)

DOMNamedNodeMap implements Traversable

readonly int $length;
DOMNode getNamedItem(string $name)
DOMNode getNamedItemNS(string $namespaceURI, string $localName)
DOMNode item(int $index)

DOMNodeList implements Traversable

readonly int $length;
DOMNode item(int $index)

DOMException extends Exception

readonly int $code;

DOMImplementation

__construct(void)
DOMDocument createDocument([string $namespaceURI = NULL [, string $qualifiedName = NULL [, DOMDocumentType $doctype = NULL]]])
DOMDocumentType createDocumentType([string $qualifiedName = NULL [, string $Id = NULL [, string $systemId = NULL]]])
bool hasFeature(string $feature, string $version)