ASPN ActiveState Programmer Network
  ActiveState, a division of Sophos
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups | Web Services
SEARCH
advanced | search help

Reference
PHP Manual
Function Reference
Apache-specific Functions
Array Functions
Aspell functions [deprecated]
BCMath Arbitrary Precision Mathematics Functions
Bzip2 Compression Functions
Calendar functions
CCVS API Functions
COM support functions for Windows
Class/Object Functions
ClibPDF functions
CURL, Client URL Library Functions
Cybercash payment functions
Crédit Mutuel CyberMUT functions
Character type functions
Database (dbm-style) abstraction layer functions
Date and Time functions
dBase functions
DBM Functions
dbx functions
DB++ Functions
Directory functions
DOM XML functions
Error Handling and Logging Functions
FrontBase Functions
filePro functions
Filesystem functions
Forms Data Format functions
FTP functions
Function Handling functions
Gettext
GMP functions
HTTP functions
Hyperwave functions
ICAP Functions
iconv functions
Image functions
IMAP, POP3 and NNTP functions
Informix functions
InterBase functions
Ingres II functions
IRC Gateway Functions
Java
LDAP functions
Mail functions
Mathematical Functions
Multi-Byte String Functions
MCAL functions
Mcrypt Encryption Functions
Mhash Functions
Microsoft SQL Server functions
Ming functions for Flash
Miscellaneous functions
mnoGoSearch Functions
mSQL functions
MySQL Functions
Network Functions
Unified ODBC functions
Oracle 8 functions
OpenSSL functions
Oracle functions
Ovrimos SQL functions
Output Control Functions
Object property and method call overloading
PDF functions
Verisign Payflow Pro functions
PHP options & information
POSIX functions
PostgreSQL functions
Program Execution functions
Printer functions
Pspell Functions
GNU Readline
GNU Recode functions
Regular Expression Functions (Perl-Compatible)
Regular Expression Functions (POSIX Extended)
Satellite CORBA client extension
Semaphore and Shared Memory Functions
SESAM database functions
Session handling functions
Shared Memory Functions
Shockwave Flash functions
SNMP functions
Socket functions
String functions
Sybase functions
URL Functions
Variable Functions
WDDX Functions
XML parser functions
XSLT functions
YAZ functions
YP/NIS Functions
Zip File Functions (Read Only Access)
Zlib Compression Functions

MyASPN >> Reference >> PHP Manual >> Function Reference
PHP Manual

XXII. DOM XML functions

Warning

This module is EXPERIMENTAL. That means, that the behaviour of these functions, these function names, in concreto ANYTHING documented here can change in a future release of PHP WITHOUT NOTICE. Be warned, and use this module at your own risk.

This documentation is not finished yet. Don't start to translate it or use it as a programming reference (steinm@php.net).

These functions are only available if PHP was configured with --with-dom=[DIR], using the GNOME xml library. You will need at least libxml-2.2.7 These functions have been added in PHP 4.

The extension allows you to operate on an XML document with the DOM API. It also provides a function xmltree() to turn the complete XML document into a tree of PHP objects. Currently this tree should be considered read-only - you can modify it but this would not make any sense since dumpmem() cannot be applied to it. Therefore, if you want to read an XML file and write a modified version use the add_node(), set_attribute(), etc. and finally dumpmem() functions.

This module defines the following constants:

Table 1. XML constants

ConstantValueDescription
XML_ELEMENT_NODE1Node is an element
XML_ATTRIBUTE_NODE2Node is an attribute
XML_TEXT_NODE3Node is a piece of text
XML_CDATA_SECTION_NODE4 
XML_ENTITY_REF_NODE5 
XML_ENTITY_NODE6Node is an entity like  
XML_PI_NODE7Node is a processing instruction
XML_COMMENT_NODE8Node is a comment
XML_DOCUMENT_NODE9Node is a document
XML_DOCUMENT_TYPE_NODE10 
XML_DOCUMENT_FRAG_NODE11 
XML_NOTATION_NODE12 
XML_GLOBAL_NAMESPACE1 
XML_LOCAL_NAMESPACE2 

Each function in this extension can be used in two ways. In a non-object oriented way by passing the object to apply the function to as a first argument, or in an object oriented way by calling the function as a method of an object. This documentation describes the non-object oriented functions, though you get the object methods by skipping the prefix "domxml_".

This module defines a number of classes, which are listed — including their properties and method — in the following table.

Table 2. DomDocument class (methods)

Method nameFunction nameDescription
rootdomxml_root() 
childrendomxml_children() 
add_rootdomxml_add_root() 
dtddomxml_intdtd() 
dumpmemdomxml() 
xpath_initxpath_init 
xpath_new_contextxpath_new_context 
xptr_new_contextxptr_new_context 

Table 3. DomDocument class (attributes)

NameTypeDescription
docclass DomDocumentThe object itself
namestring 
urlstring 
versionstringVersion of XML
encodingstring 
standalonelong1 if the file is a standalone version
typelongOne of the constants in table ...
compressionlong1 if the file is compressed
charsetlong 

Table 4. DomNode class (methods)

NamePHP nameDescription
lastchilddomxml_last_child() 
childrendomxml_children() 
parentdomxml_parent() 
new_childdomxml_new_child() 
get_attributedomxml_get_attribute() 
set_attributedomxml_set_attribute() 
attributesdomxml_attributes() 
nodedomxml_node() 
set_content()domxml_set_content 

Table 5. DomNode class (attributes)

NameTypeDescription
nodeclass DomNodeThe object itself
typelong 
namestring 
contentstring 

Table of Contents
xmldoc -- Creates a DOM object of an XML document
xmldocfile -- Creates a DOM object from XML file
xmltree --  Creates a tree of PHP objects from XML document
domxml_root --  Returns root element node
domxml_add_root --  Adds a further root node
domxml_dumpmem --  Dumps the internal XML tree back into a string
domxml_attributes --  Returns an array of attributes of a node
domxml_get_attribute --  Returns a certain attribute of a node
domxml_set_attribute -- 
domxml_children --  Returns children of a node or document
domxml_new_child --  Adds new child node
domxml_new_xmldoc --  Creates new empty XML document
xpath_new_context --  Creates new xpath context
xpath_eval --  Evaluates an xpath expression

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2003 ActiveState, a division of Sophos All rights reserved