XXV. DOM XML functions

Introduction

אזהרה

רכיב זה הוא ניסיוני . כלומר , התנהגות הפונקציות,שמות הפונקציות ובאופן כללי כל מה שמתועד כאן עשוי להשתנות בהפצה עתידית של PHP ללא התרעה . ראה הוזהרת , השימוש ברכיב זה על אחריותך בלבד .

The domxml extension has been overhauled in PHP Version 4.3.0 in favour of a better compliance of the DOM standard . The extension still contains many old functions , but they should not be used anymore . Especially those non object oriented functions should be avoided .

Currently this tree should be considered read-only - you can modify it but this would not make any sense since DomDocument_dump_mem( ) cannot be applied to it . Therefore , if you want to read an XML file and write a modified version use the DomDocument_create_element( ) , DomDocument_create_text_node( ) , set_attribute( ) , etc . and finally DomDocument_dump_mem( ) functions .

Requirements

This extension make use of the GNOME xml library . You will need at least libxml-2.2.7 .

Installation

This extension is only available if PHP was configured with --with-dom=[ DIR ] .

Deprecated functions

There a quite some functions which do not fit into the DOM standard and should not be used anymore as listed in the following table . The function DomNode_append_child( ) has changed its behaviour . It now actually adds a child and not a sibling . If this breaks your application use the non DOM function DomNode_append_sibling( ) .

טבלה 1 . Deprecated functions and its replacements

xmldocfiel
DomDocument_create_text_node( ) und add it with DomNode_append_child( ) .


Predefined Constants

These constants are defined by this extension , and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime .

טבלה 2 .

Classes

The API of the module follows the DOM Level 2 standard as close as possible . Consequently the API is fully object oriented . Though the API is object oriented there are many functions which can be called in a non-object oriented way by passing the object to operate on as the first argument . These function are mainly to retain compatibilty to older versions of the extension but are not encouraged to use anymore in new developments .

This API differs from the official DOM API in two points . First , all class attributes are implemented as functions with the same name and secondly the function names follow the PHP naming convention .

Classes with an equivalent in the DOM Standard are named DOMxxx .

טבלה 3 .









טבלה 7 .



טבלה 8 .



טבלה 9 .



טבלה 10 .



טבלה 11 .



DomComment is derived from DomCData

Examples

Many examples in this reference require a xml string . Instead of repeating this string in any example it will be put into a file and be included by each example . You could also create an xml document read it with DomDocument_open_file( ) .

דוגמה 1 . Include file example.inc with xml string






תוכן העניינים :
-- Returns name of attribute
DomAttribute- specified -- Checks if attribute is specified
DomAttribute- value -- Returns value of attribute
DomDocument- add_root [deprecated] -- Adds a root node
DomDocument- create_attribute -- Create new attribute
DomDocument- create_cdata_section -- Create new cdata node
DomDocument- create_comment -- Create new comment node
DomDocument- create_element -- Create new element node
DomDocument- create_entity_reference --
DomDocument- create_processing_instruction -- Creates new PI node
DomDocument- create_text_node -- Create new text node
DomDocument- doctype -- Returns the document type
DomDocument- document_element -- Returns root element node
DomDocument- dump_file -- Dumps the internal XML tree back into a file
DomDocument- dump_mem -- Dumps the internal XML tree back into a string
DomDocument- get_element_by_id -- Searches for an element with a certain id
DomDocument- get_elements_by_tagname --
DomDocument- html_dump_mem -- Dumps the internal XML tree back into a string as HTML
DomDocumentType- entities -- Returns list of entities
DomDocumentType- internal_subset -- Returns internal subset
DomDocumentType- name -- Returns name of document type
DomDocumentType- notations -- Returns list of notations
DomDocumentType- public_id -- Returns public id of document type
DomDocumentType- system_id -- Returns system id of document type
DomElement- get_attribute -- Returns value of attribute
DomElement- get_attribute_node -- Returns value of attribute
DomElement- get_elements_by_tagname -- Adds new attribute
DomElement- has_attribute -- Adds new attribute
DomElement- remove_attribute -- Adds new attribute
DomElement- set_attribute -- Adds new attribute
DomElement- set_attribute_node -- Adds new attribute
DomElement- tagname -- Returns name of element
DomNode- append_child -- Adds new child at the end of the children
DomNode- append_sibling -- Adds new sibling to a node
DomNode- attributes -- Returns list of attributes
DomNode- child-nodes -- Returns children of node
DomNode- clone_node -- Clones a node
DomNode- dump_node -- Dumps a single node
DomNode- first_child -- Returns first child of node
DomNode- get_content -- Gets content of node
DomNode- has_attributess -- Checks if node has attributes
DomNode- has_child_nodes -- Checks if node has children
DomNode- insert_before -- Inserts new node as child
DomNode- is_blank_node -- Checks if node is blank
DomNode- last_child -- Returns last child of node
DomNode- next_sibling -- Returns the next sibling of node
DomNode- node_name -- Returns name of node
DomNode- node_type -- Returns type of node
DomNode- node_value -- Returns value of a node
DomNode- owner_document -- Returns the document this node belongs to
DomNode- parent_node -- Returns the parent of the node
DomNode- prefix -- Returns name space prefix of node
DomNode- previous_sibling -- Returns the previous sibling of node
DomNode- remove_child -- Removes child from list of children
DomNode- replace_child -- Replaces a child
DomNode- replace_node -- Replaces node
DomNode- set_content -- Sets content of node
DomNode- set_name -- Sets name of node
DomNode- unlink_node -- Deletes node
DomProcessingInstruction- data -- Returns data of pi node
DomProcessingInstruction- target -- Returns target of pi node
domxml_new_doc -- Creates new empty XML document
domxml_open_file -- Creates a DOM object from XML file
domxml_open_mem -- Creates a DOM object of an XML document
domxml_version -- Get XML library version
domxml_xmltree -- Creates a tree of PHP objects from an XML document
xpath_eval -- Evaluates the XPath Location Path in the given string
xpath_eval_expression -- Evaluates the XPath Location Path in the given string
xpath_new_context -- Creates new xpath context
xptr_eval -- Evaluate the XPtr Location Path in the given string
xptr_new_context -- Create new XPath Context