XML document object model (DOM) functions are used to create strings, objects, and trees representing XML documents.The functions can be called as methods of an object or by passing the object to apply the function to; both function prototypes are shown in each function definition. The aliase(s) of the function are noted below, along with any attributes of objects. This extension uses libxml 2.2.7 or greater and can be configured with --with-dom=[dir]. For more information on compiling goto http://www.php.net and look at the user contributed notes for this extension. http://www.xmlsoft.org has more information on the libxml library. The XMLDOM for this extension doesn't expose all the functionality of the libxml API. For the XML DOM specification goto http://www.w3.org/.
This extension is very new and is subject to change.
Document Object Properties:
| Name | Type | Description |
|---|---|---|
| doc | object | A reference to itself |
| name | string | Document name |
| url | string | Document URL |
| version | string | The version of XML |
| encoding | string | Document encoding |
| standalone | long | The file is a standalone version. 1=true, -1=false |
| type | long | Type of Document |
| compression | long | The file is compressed. 1=true, -1=false |
| charset | long | character set |
Document Object Methods:
| Method | Equivalent extension function |
|---|---|
| root | domxml_root |
| add_root | domxml_add_root |
| dumpmem | domxml_dumpmem |
| xpath_init | xpath_init |
| xpath_new_context | xpath_new_context |
| xptr_new_context | xptr_new_context |
Node Object Properties:
| Name | Type | Description |
|---|---|---|
| node | object | A reference to itself |
| type | long | Node type constant |
| name | string | The tag name |
| content | string | The content of the tag |
Node Object Methods:
| Methods | Equivalent extension function |
|---|---|
| children | domxml_children |
| new_child | domxml_new_child |
| get_attribute, getattr | domxml_get_attribute, domxml_getattr |
| set_attribute, setattr | domxml_set_attribute, domxml_setattr |
| unlink | domxml_unlink_node |
| node | domxml_node |
Node type Constants:
| Constant | Description |
|---|---|
| XML_ELEMENT_NODE | an element node |
| XML_ATTRIBUTE_NODE | an attribute node |
| XML_TEXT_NODE | some text node |
| XML_CDATA_SECTION_NODE | a cdata section node |
| XML_ENTITY_REF_NODE | an enitity reference node |
| XML_ENTITY_NODE | an entity node |
| XML_PI_NODE | a process instruction node |
| XML_COMMENT_NODE | a comment node |
| XML_DOCUMENT_NODE | a document node |
| XML_DOCUMENT_TYPE_NODE | a document type node |
| XML_DOCUMENT_FRAG_NODE | a document fragment node |
| XML_NOTATION_NODE | a notation node |
| XML_HTML_DOCUMENT_NODE | an HTML document node |
| XML_DTD_NODE | a DTD node |
| XML_ELEMENT_DECL_NODE | a element delcaration node |
| XML_ATTRIBUTE_DECL_NODE | an attribute declaration node |
| XML_ENTITY_DECL_NODE | an entity declaration node |
| XML_NAMESPACE_DECL_NODE | a namespace declaration node |
| XML_GLOBAL_NAMESPACE | global namespace |
| XML_LOCAL_NAMESPACE | local namespace |
Attribute Type Constants:
| Constant | Description |
|---|---|
| XML_ATTRIBUTE_CDATA | CDATA attribute |
| XML_ATTRIBUTE_ID | ID attribute |
| XML_ATTRIBUTE_IDREF | IDREF attribute |
| XML_ATTRIBUTE_IDREFS | IDREFS attribute |
| XML_ATTRIBUTE_ENTITY | ENTITY attribute |
| XML_ATTRIBUTE_NMTOKEN | NMTOKEN attribute |
| XML_ATTRIBUTE_NMTOKENS | NMTOKENS attribute |
| XML_ATTRIBUTE_ENUMERATION | ENUMERATION attribute |
| XML_ATTRIBUTE_NOTATION | NOTATION attribute |
XPath Type Constants:
| Constant | Description |
|---|---|
| XPATH_UNDEFINED | undefined data type |
| XPATH_NODESET | An XPath nodeset |
| XPATH_BOOLEAN | boolean data type |
| XPATH_NUMBER | number data type |
| XPATH_STRING | string data type |
| XPATH_POINT | point data type |
| XPATH_RANGE | an XPath range |
| XPATH_LOCATIONSET | an XPath location set |
| XPATH_USERS | XPath users |