diff --git a/reference/dom/functions/dom-domnode-appendchild.xml b/reference/dom/functions/dom-domnode-appendchild.xml index 656417757c..a16fd4f8c9 100644 --- a/reference/dom/functions/dom-domnode-appendchild.xml +++ b/reference/dom/functions/dom-domnode-appendchild.xml @@ -1,50 +1,86 @@ - - - - DOMNode->appendChild - - Adds new child at the end of the children - - - - &reftitle.description; - - DOMNode - - DOMNode - appendChild - DOMNodenewnode - - - - This functions appends a child to an existing list of children or creates - a new list of children. The child can be created with e.g. - DOMDocument->createElement(), - DOMDocument->createTextNode() - etc. or simply by using any other node. - - - Throws DOMException if node cannot be appended. - - - The following example will add a new element node to a fresh document. - - Adding a child - + + + + DOMNode->appendChild + + Adds new child at the end of the children + + + + &reftitle.description; + + DOMNode + + DOMNode + appendChild + DOMNodenewnode + + + + This functions appends a child to an existing list of children or creates + a new list of children. The child can be created with e.g. + DOMDocument->createElement(), + DOMDocument->createTextNode() + etc. or simply by using any other node. + + + Throws DOMException if the node cannot be appended. + + + + &reftitle.parameters; + + + + newnode + + + The appended child. + + + + + + + + &reftitle.returnvalues; + + The node added. + + + + &reftitle.examples; + + The following example will add a new element node to a fresh document. + + Adding a child + createElement("para"); $newnode = $doc->appendChild($node); -print $doc->saveXML(); + +echo $doc->saveXML(); ?> ]]> - - - - - + + + + + + &reftitle.seealso; + + + DOMNode->removeChild() + DOMNode->replaceChild() + + + + - - - DOMNode->hasAttributes - - Checks if node has attributes - - - - &reftitle.description; - - DOMNode - - bool - hasAttributes - - - - - This function checks if the node has attributes. - - - + + + + DOMNode->hasAttributes + + Checks if node has attributes + + + + &reftitle.description; + + DOMNode + + bool + hasAttributes + + + + + This function checks if the node has attributes. + + + + &reftitle.returnvalues; + + &return.success; + + + - - - DOMNode->hasChildNodes - - Checks if node has children - - - - &reftitle.description; - - DOMNode - - bool - hasChildNodes - - - - - This function checks if the node has children. - - - + + + + DOMNode->hasChildNodes + + Checks if node has children + + + + &reftitle.description; + + DOMNode + + bool + hasChildNodes + + + + + This function checks if the node has children. + + + + &reftitle.returnvalues; + + &return.success; + + + - - - DOMNode->removeChild - - Removes child from list of children - - - - &reftitle.description; - - DOMNode - - DOMNode - removeChild - DOMNodeoldchild - - - - This functions removes a child from a list of children. - If the child could be removed the functions returns the old child. - - - Throws DOMException if node cannot be removed. - - - + + + + DOMNode->removeChild + + Removes child from list of children + + + + &reftitle.description; + + DOMNode + + DOMNode + removeChild + DOMNodeoldnode + + + + This functions removes a child from a list of children. + + + Throws DOMException if the node cannot be removed. + + + + &reftitle.parameters; + + + + oldnode + + + The removed child. + + + + + + + + &reftitle.returnvalues; + + If the child could be removed the functions returns the old child. + + + + &reftitle.examples; + + The following example will delete the chapter element of our XML document. + + Removing a child + +load('book.xml'); + +$book = $doc->documentElement; + +// we retrieve the chapter and remove it from the book +$chapter = $book->getElementsByTagName('chapter')->item(0); +$oldchapter = $book->removeChild($chapter); + +echo $doc->saveXML(); +?>]]> + + &example.outputs; + + + + + My lists + + +]]> + + + + + + &reftitle.seealso; + + + DOMNode->appendChild() + DOMNode->replaceChild() + + + + - - - DOMNodelist->item - - Retrieves a node specified by index - - - - &reftitle.description; - - DOMNodeList - - DOMNode - item - intindex - - + + + + DOMNodelist->item + + Retrieves a node specified by index + + + + &reftitle.description; + + DOMNodeList + + DOMNode + item + intindex + + + + Retrieves a node specified by index within the + DOMNodeList object. + + + + If you need to know the number of nodes in the collection, use + the length property of the + DOMNodeList object. + + + + + &reftitle.parameters; + + + + index + + + Index of the node into the collection. + + + + + + + + &reftitle.returnvalues; + + The node at the indexth position in the + DOMNodeList, or &null; if that is not a valid + index. + + + + &reftitle.examples; + + + Traversing all the entries of the table + +load('book.xml'); + +$items = $doc->getElementsByTagName('entry'); + +for ($i = 0; $i < $items->length; $i++) { + echo $items->item($i)->nodeValue . "\n"; +} + +?> +]]> + - Retrieves a node specified by index within the - DOMNodeList object. + Alternatively, you can use foreach, which is a much more convenient way: - - + +nodeValue . "\n"; +} + +?> +]]> + + &example.outputs; + + + + + + + + DOM Functions DOM @@ -289,19 +289,26 @@ doctype DOMDocumentType yes - + + The Document Type Declaration associated with this document. + documentElement DOMElement yes - + + This is a convenience attribute that allows direct access to the + child node that is the document element of the document. + documentURI string no - + + The location of the document or &null; if undefined. + encoding @@ -319,7 +326,10 @@ implementation DOMImplementation yes - + + The DOMImplementation object that handles + this document. + preserveWhiteSpace @@ -377,19 +387,30 @@ xmlEncoding string yes - + + An attribute specifying, as part of the XML declaration, the + encoding of this document. This is &null; when unspecified or when it + is not known, such as when the Document was created in memory. + xmlStandalone bool no - + + An attribute specifying, as part of the XML declaration, whether + this document is standalone. This is &false; when unspecified. + xmlVersion string no - + + An attribute specifying, as part of the XML declaration, the + version number of this document. If there is no declaration and if + this document supports the "XML" feature, the value is "1.0". + @@ -402,6 +423,11 @@ Extends DOMNode + + Each DOMDocument has a + doctype attribute whose value is either &null; or a + DOMDocumentType object. +
&reftitle.properties; @@ -420,37 +446,48 @@ publicIdstringyes - + The public identifier of the external subset. systemId string yes - + The system identifier of the external subset. This may be an + absolute URI or not. name string yes - + The name of DTD; i.e., the name immediately following the + DOCTYPE keyword. entities DOMNamedNodeMap yes - + + A DOMNamedNodeMap containing the general + entities, both external and internal, declared in the DTD. + notations DOMNamedNodeMap yes - + + A DOMNamedNodeMap containing the notations + declared in the DTD. + internalSubset string yes - + + The internal subset as a string, or null if there is none. This is + does not contain the delimiting square brackets. + @@ -550,6 +587,10 @@ Extends DOMNode + + This interface represents a known entity, either parsed or unparsed, in + an XML document. +
&reftitle.properties;
@@ -568,37 +609,59 @@ publicIdstringyes - + + The public identifier associated with the entity if specified, and + &null; otherwise. + systemId string yes - + + The system identifier associated with the entity if specified, and + &null; otherwise. This may be an absolute URI or not. + notationName string yes - + + For unparsed entities, the name of the notation for the entity. For + parsed entities, this is &null;. + actualEncoding string no - + + An attribute specifying the encoding used for this entity at the + time of parsing, when it is an external parsed entity. This is + &null; if it an entity from the internal subset or if it is not + known. + encoding string yes - + + An attribute specifying, as part of the text declaration, the + encoding of this entity, when it is an external parsed entity. This + is &null; otherwise. + version string - no - + yes + + An attribute specifying, as part of the text declaration, the + version number of this entity, when it is an external parsed + entity. This is &null; otherwise. + @@ -706,7 +769,11 @@ lengthintyes - + + The number of pairs (name and namespaceURI) in the list. The range + of valid child node indices is 0 to length - 1 + inclusive. + @@ -782,7 +849,7 @@ nodeValuestringno - + The value of this node, depending on its type. nodeType @@ -794,79 +861,114 @@ parentNode DOMNode yes - + The parent of this node. childNodes DOMNodeList yes - + + A DOMNodeList that contains all children of + this node. If there are no children, this is an empty + DOMNodeList. + firstChild DOMNode yes - + + The first child of this node. If there is no such node, this + returns &null;. + lastChild DOMNode yes - + + The last child of this node. If there is no such node, this returns + &null;. + previousSibling DOMNode yes - + + The node immediately preceding this node. If there is no such node, + this returns &null;. + nextSibling DOMNode yes - + + The node immediately following this node. If there is no such node, + this returns &null;. + attributes - DomNamedNodeMap + DOMNamedNodeMap yes - + + A DOMNamedNodeMap containing the attributes + of this node (if it is a DOMElement) or + &null; otherwise. + ownerDocument DOMDocument yes - + + The DOMDocument object associated with this + node. + namespaceURI string yes - + + The namespace URI of this node, or &null; if it is unspecified. + prefix string no - + + The namespace prefix of this node, or &null; if it is unspecified. + localName string yes - + + Returns the local part of the qualified name of this node. + baseURI string yes - + + The absolute base URI of this node or &null; if the implementation + wasn't able to obtain an absolute URI. + textContent string no - + + This attribute returns the text content of this node and its + descendants. +