| PHP Ръководство | ||
|---|---|---|
| Предишна страница | Следваща страница | |
The DOM extension allows you to operate on XML documents through the DOM API with PHP 5.
For PHP 4, use DOM XML.
Забележка: DOM extension uses UTF-8 encoding. Use utf8_encode() and utf8_decode() to work with texts in ISO-8859-1 encoding or Iconv for other encodings.
Не е необходимо инсталиране, за да се използват тези функции. Те са част от ядрото на PHP.
The API of the module follows the DOM Level 3 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 explained in the following tables. Classes with an equivalent in the DOM standard are named DOMxxx.
Extends DOMNode. The DOMAttr interface represents an attribute in an DOMElement object.
- construct a new DOMAttr object
- Checks if attribute is a defined ID
Extends DOMNode.
- Append a string to the end of the character data of the node
- Remove a range of characters from the node
- Insert a string at the specified 16-bit unit offset
- Replace a substring within the DOMCharacterData node
- Extracts a range of data from the node
Extends DOMNode.
- construct a new DOMDocument object
- Create new attribute
- Create new attribute node with an associated namespace
- Create new cdata node
- Create new comment node
- Create new document fragment
- Create new element node
- Create new element node with an associated namespace
- Create new entity reference node
- Creates new PI node
- Create new text node
- Searches for an element with a certain id
- Searches for all elements with given tag name
- Searches for all elements with given tag name in specified namespace
- Import node into current document
- Load XML from a file
- Load HTML from a string
- Load HTML from a file
- Load XML from a string
- Normalizes the document
- Performs relaxNG validation on the document
- Performs relaxNG validation on the document
- Register extended class used to create base node type (not DOM standard)
- Dumps the internal XML tree back into a file
- Dumps the internal document into a string using HTML formatting
- Dumps the internal document back into a file using HTML formatting
- Dumps the internal XML tree back into a string
- Validates a document based on a schema
- Validates a document based on a schema
- Validates the document based on its DTD
- Substitutes XIncludes in a DOMDocument Object
Extends DOMNode
Each DOMDocument has a doctype attribute whose value is either NULL or a DOMDocumentType object.
Extends DOMNode.
- construct a new DOMElement object
- Returns value of attribute
- Returns attribute node
- Returns attribute node
- Returns value of attribute
- Gets elements by tagname
- Get elements by namespaceURI and localName
- Checks to see if attribute exists
- Checks to see if attribute exists
- Removes attribute
- Removes attribute
- Removes attribute
- Adds new attribute
- Adds new attribute node to element
- Adds new attribute node to element
- Adds new attribute
- Declares the ID attribute
- Declares the ID attribute
- Declares the ID attribute
Extends DOMNode
This interface represents a known entity, either parsed or unparsed, in an XML document.
DOM operations raise exceptions under particular circumstances, i.e., when an operation is impossible to perform for logical reasons.
See also .
The DOMImplementation interface provides a number of methods for performing operations that are independent of any particular instance of the document object model.
- construct a new DOMImplementation object
- Creates a DOM Document object of the specified type with its document element
- Creates an empty DOMDocumentType object
- Test if the DOM implementation implements a specific feature
- Retrieves a node specified by name
- Retrieves a node specified by local name and namespace URI
- Retrieves a node specified by index
- Adds new child at the end of the children
- Clones a node
- Checks if node has attributes
- Checks if node has children
- Adds a new child before a reference node
- Checks if the specified namespaceURI is the default namespace
- Indicates if two nodes are the same node
- Checks if feature is supported for specified version
- Returns namespace URI of the node based on the prefix
- Returns name space prefix of the node based on namespaceURI
- Normalizes the node
- Removes child from list of children
- Replaces a child
Extends DOMNode.
- construct a new DOMProcessingInstruction object
Extends DOMCharacterData.
- construct a new DOMText object
- Indicates whether this text node contains whitespace
- Breaks the node into two nodes at the specified offset
- construct a new DOMXPath object
- Registers the namespace with the DOMXpath object
- Evaluates the given XPath expression and returns a typed result if possible
- Evaluates the given XPath expression
Many examples in this reference require an XML file. We will use book.xml that contains the following:
Константите по-долу са дефинирани в това разширение и ще бъдат налични единствено, когато това разширение е компилирано в PHP или динамично пуснато по време на изпълнение.
| Предишна страница | Начало | Следваща страница |
| scandir | Начало на раздела | DOMAttr->__construct() |