The DOM extension is the replacement for the domxml extension from PHP 4. The extension still contains many old functions, but they should no longer be used. In particular, functions that are not object-oriented should be avoided.
The extension allows you to operate on an XML document with the DOM API.
以下的常數由此延伸定義,只在這個延伸被編譯成PHP或實行時期被動態載入時有效。
表格 1. XML constants
Constant | Value | Description |
---|---|---|
XML_ELEMENT_NODE (integer) | 1 | Node is an element |
XML_ATTRIBUTE_NODE (integer) | 2 | Node is an attribute |
XML_TEXT_NODE (integer) | 3 | Node is a piece of text |
XML_CDATA_SECTION_NODE (integer) | 4 | |
XML_ENTITY_REF_NODE (integer) | 5 | |
XML_ENTITY_NODE (integer) | 6 | Node is an entity like |
XML_PI_NODE (integer) | 7 | Node is a processing instruction |
XML_COMMENT_NODE (integer) | 8 | Node is a comment |
XML_DOCUMENT_NODE (integer) | 9 | Node is a document |
XML_DOCUMENT_TYPE_NODE (integer) | 10 | |
XML_DOCUMENT_FRAG_NODE (integer) | 11 | |
XML_NOTATION_NODE (integer) | 12 | |
XML_HTML_DOCUMENT_NODE (integer) | 13 | |
XML_DTD_NODE (integer) | 14 | |
XML_ELEMENT_DECL_NODE (integer) | 15 | |
XML_ATTRIBUTE_DECL_NODE (integer) | 16 | |
XML_ENTITY_DECL_NODE (integer) | 17 | |
XML_NAMESPACE_DECL_NODE (integer) | 18 | |
XML_ATTRIBUTE_CDATA (integer) | 1 | |
XML_ATTRIBUTE_ID (integer) | 2 | |
XML_ATTRIBUTE_IDREF (integer) | 3 | |
XML_ATTRIBUTE_IDREFS (integer) | 4 | |
XML_ATTRIBUTE_ENTITY (integer) | 5 | |
XML_ATTRIBUTE_NMTOKEN (integer) | 7 | |
XML_ATTRIBUTE_NMTOKENS (integer) | 8 | |
XML_ATTRIBUTE_ENUMERATION (integer) | 9 | |
XML_ATTRIBUTE_NOTATION (integer) | 10 |
表格 2. DOMException constants
Constant | Value | Description |
---|---|---|
DOM_INDEX_SIZE_ERR (integer) | 1 | |
DOMSTRING_SIZE_ERR (integer) | 2 | |
DOM_HIERARCHY_REQUEST_ERR (integer) | 3 | |
DOM_WRONG_DOCUMENT_ERR (integer) | 4 | |
DOM_INVALID_CHARACTER_ERR (integer) | 5 | |
DOM_NO_DATA_ALLOWED_ERR (integer) | 6 | |
DOM_NO_MODIFICATION_ALLOWED_ERR (integer) | 7 | |
DOM_NOT_FOUND_ERR (integer) | 8 | |
DOM_NOT_SUPPORTED_ERR (integer) | 9 | |
DOM_INUSE_ATTRIBUTE_ERR (integer) | 10 | |
DOM_INVALID_STATE_ERR (integer) | 11 | |
DOM_SYNTAX_ERR (integer) | 12 | |
DOM_INVALID_MODIFICATION_ERR (integer) | 13 | |
DOM_NAMESPACE_ERR (integer) | 14 | |
DOM_INVALID_ACCESS_ERR (integer) | 15 | |
DOM_VALIDATION_ERR (integer) | 16 |
The API of the module follows the DOM Level 2 standard as closely as possible. Consequently, the API is fully object-oriented. It is a good idea to have the DOM standard available when using this module.
This module defines a number of classes, which are listed - including their method - in the following tables. Classes with an equivalent in the DOM standard are named DOMxxx.
表格 3. List of classes
Class name | Parent classes |
---|---|
DOMAttr | DOMNode |
DOMCDataSection | DOMText : DOMNode |
DOMCharacterData | DOMNode |
DOMComment | DOMCharacterData : DomNode |
DOMDocument | DOMNode |
DOMDocumentFragment | DOMNode |
DOMDocumentType | DOMNode |
DOMElement | DOMNode |
DOMEntity | DOMNode |
DOMEntityReference | DOMNode |
DOMNode | |
DOMNotation | DOMNode |
DOMProcessingInstruction | DOMNode |
DOMText | DOMCDataSection : DomNode |
DOMException | |
DOMImplementation | |
DOMNamedNodeMap | |
DOMNodeList | |
DOMXPath |