Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: /usr/local/apache_8080/htdocs/devel/Intra/class/phpdom/domxml_node.php
Document Object Model for PHP - phpDOM

Node

Node

The Node-Class

 

private class Node

The Node-Class
Base Class for all Nodes in a DOM TreeThe Node interface is the primary datatype for the entire Document Object Model.All other objects inherit from this class.

AuthorsDietmar Glachs <dietmar.glachs@salzburgresearch.at>
Versiondevel.0.4
Copyright2000 Salzburg Research Gesellschaft m.b.H.

 
Direct known subclasses: Element, Document, CharacterData

Public Method Summary

object Node

appendChild(object Node $NewChild)

appendChild adds a new node to the current node.
object Node

cloneNode(boolean $deep)

cloneNode clones the current node!
boolean

removeChild(object Node $ChildToRemove)

removeChild deletes a child node of the current node
object Document

getOwnerDocument()

getOwnerDocument retrieves the document object associated with this node
object Node

getFirstChild()

getFirstChild
object Node

getNextChild()

getNextChild
object Element

getLastChild()

getLastChild
object Node

getNodeById(string $IdToSearch)

getNodeById
boolean

hasChildNodes()

Checks for subsequent elements
object Node

getParentNode()

getParentNode returns the parent node of the current node, false if no parent is present!
object Node

getParent()

getParent returns the parent node of the current node, false if no parent is present!
object NodeList

getChildNodes()

getChildNodes returns a list of all child nodes of the current node
boolean

setNodeValue(string $value)

setNodeValue sets the content of the current node.
string

getNodeValue()

getNodeValue returns the Value of the node, if present
object NamedNodeMap

getAttributes()

getAttributes returns an array with the attributes set
string

toString()

toString
string

getNodeName()

getNodeName The name of the node
int

getNodeType()

getNodeType
object Node

addElement(object Node $elem)

adds a new element to the end of the elementlist

Private Method Summary

void

Node([ string $tag, string $content ])

Constructor of the Node
boolean

Tag(string $tag, [ boolean $hasClosing ])

Tag specifies the name of the tag such as table, tr, td, span, p, body etc. for HTML-Documents
boolean

hasMoreElements()

Checks, whether threre are more Elements
string

_internal_toString(object DomNode $NodeToString, string &$retstr)

creates and retrieves the text representation of the current node
object DomNode

_internal_cloneNode(object DomNode $NodeToAdd, object DomNode $NodeToClone, [ boolean $deep ])

_internal_cloneNode clones a node
boolean

_internal_selfCheck()

_internal_selfCheck checks the current node, whether it is linked to a document or not!
object DomNode

_internal_getNodeById(object DomNode $search, string $IdToSearch)

_internal_getNodeById

Private Field Summary

string

$nodeName

The Name of the Node.
string

$nodevalue

The Value of the node, used as <tag> $nodevalue </tag>
array

$attribute

Array with all attributes for the node
object DomNode

$node

contains the DomNode Object

Public Method Details

appendChild

public object Node appendChild( object Node $NewChild )

  appendChild adds a new node to the current node.
appendChild adds a new node to the current node. If the current node is not yetattached to the document, a independent node will be created and the new node willbe attached to the independent node. This will be a document independent tree!It is possible to clone the independent tree to the document by appending the rootelement to a node of the document.

Parameter
object Node $NewChild
Returns object Node

See Also _internal_selfCheck(), _internal_cloneNode()

cloneNode

public object Node cloneNode( boolean $deep )

  cloneNode clones the current node!
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent ( getParentNode() returns null.).

Parameter
boolean $deep
Specifies whether to perform a deep clone or not.
Returns object Node

The cloned object!


removeChild

public boolean removeChild( object Node $ChildToRemove )

  removeChild deletes a child node of the current node
since the domxml functions donīt provide a method to remove a node, thisis currently not supported!

Parameter
object Node $ChildToRemove
The node to be deleted
Returns boolean

true if the deletion was successful, false otherwise

Deprecated Currently deprecated because of the missing of an appropriate domxml_... function.

getOwnerDocument

public object Document getOwnerDocument( )

  getOwnerDocument retrieves the document object associated with this node
since the domxml functions donīt provide a method to retrieve the associated document, thisis currently not supported!

Returns object Document

The Document object

Magic Currently not available because of the missing of an appropriate domxml_... function.

getFirstChild

public object Node getFirstChild( )

  getFirstChild
returns a object linked to the first element of the current node.If there is no child node, it will return false.

Returns object Node $FirstChild


getNextChild

public object Node getNextChild( )

  getNextChild
returns a object linked to the first element of the current node.If there is no child node, it will return false.

Returns object Node $NextChild


getLastChild

public object Element getLastChild( )

  getLastChild
returns a object linked to the last element of the current node.If there is no child node, it will return false.

Returns object Element $LastChild


getNodeById

public object Node getNodeById( string $IdToSearch )

  getNodeById
parses the children of the current node for a node with a given "id" attribute.If such a node can be found, the object will be returned, false otherwise.

Parameter
string $IdToSearch
Returns object Node $NodeOfId


hasChildNodes

public boolean hasChildNodes( )

  Checks for subsequent elements

Returns boolean

Returns true, if the current element has child nodes, false otherwise

See Also getFirstChild(), getNextChild(), hasMoreElements()

getParentNode

public object Node getParentNode( )

  getParentNode returns the parent node of the current node, false if no parent is present!
Note: This function may cause an error! If you call this function from the root element,the parser crashes.

Returns object Node

The parent node.


getParent

public object Node getParent( )

  getParent returns the parent node of the current node, false if no parent is present!
Note: This function may cause an error! If you call this function from the root element,the parser crashes.

Returns object Node

The parent node.

Deprecated Use getParentNode() instead

getChildNodes

public object NodeList getChildNodes( )

  getChildNodes returns a list of all child nodes of the current node
Note: This function may cause an error! If you call this function from the root element,the parser crashes.

Returns object NodeList

An object containing all child elements


setNodeValue

public boolean setNodeValue( string $value )

  setNodeValue sets the content of the current node.
setNodeValue stores the given parameter as the content of the current node.

Parameter
string $value
value of the node
Returns boolean

Returns true if the value has been successfully set, false otherwise.

See Also $nodevalue

getNodeValue

public string getNodeValue( )

  getNodeValue returns the Value of the node, if present

Returns string

The value of the node


getAttributes

public object NamedNodeMap getAttributes( )

  getAttributes returns an array with the attributes set

Returns object NamedNodeMap $attributes


toString

public string toString( )

  toString
creates and retrieves the text representation of the current node

Returns string $retstr

The string, which represents the current node


getNodeName

public string getNodeName( )

  getNodeName The name of the node
retrieves the name of the current node. Text-Nodes have no name, therefore thefunction returns an empty string.

Returns string $name


getNodeType

public int getNodeType( )

  getNodeType
returns the type of the nodeThe type of the node can be either-> 1 - XML_ELEMENT_NODE-> 2 - XML_ATTRIBUTE_NODE-> 3 - XML_TEXT_NODE-> 4 - XML_CDATA-> 5 - XML_ENTITY_REF_NODE-> 6 - XML_ENTITY_NODE-> 7 - XML_PI_NODE-> 8 - XML_COMMENT_NODE-> 9 - XML_DOCUMENT_NODE-> 10 - XML_DOCUMENT_TYPE_NODE-> 11 - XML_DOCUMENT_FRAG_NODE-> 12 - XML_NOTATION_NODE

Returns int $type

The type of the underlying object!


addElement

public object Node addElement( object Node $elem )

  adds a new element to the end of the elementlist
This function does not return a reference to the inserted Object.If you intend to insert only one element, its reference will be returnd.When inserting an array, the function always returns true!

Parameter
object Node $elem
Element, to be added to the current node. This may
be an array too.
Returns object Node

The newly inserted node, now linked to the document, is returned.

Deprecated Please use appendChild instead!
See Also appendChild()

Private Method Details

Node

private void Node( [ string $tag, string $content ] )

  Constructor of the Node
This is a constructor for simple usage of nodes. Derived classes, and thenode class should not be used directly, will define their own constructor.

Parameter
string $tag = >>""<<
of the node
string $content = >>""<<
, the content of the node
Returns void


Tag

private boolean Tag( string $tag, [ boolean $hasClosing ] )

  Tag specifies the name of the tag such as table, tr, td, span, p, body etc. for HTML-Documents

Parameter
string $tag
of the tag
boolean $hasClosing = >>true<<
, defaults to true. Indicates whether a closing tag exists or not
Returns boolean

returns always true


hasMoreElements

private boolean hasMoreElements( )

  Checks, whether threre are more Elements

Returns boolean

Returns true, if the current element has more child nodes.

See Also getFirstChild(), getNextChild()

_internal_toString

private string _internal_toString( object DomNode $NodeToString, string &$retstr )

  creates and retrieves the text representation of the current node
creates and retrieves the text representation of the current node. This functionsdeals with DomNode-Objects, it is for internal use only.

Parameter
object DomNode $NodeToString
The node to create the string
string &$retstr
reference to a string. The representation of the current node
will be appended to this string.
Returns string

The text representation of the current DomNode

Magic This function works on >> DomNode << objects, never use directly.
See Also toString()

_internal_cloneNode

private object DomNode _internal_cloneNode( object DomNode $NodeToAdd, object DomNode $NodeToClone, [ boolean $deep ] )

  _internal_cloneNode clones a node
This private function copies a independent node to a "already attached" node. Thisfunctions deals with >>DomNode<< Objects!

Parameter
object DomNode $NodeToAdd
object DomNode $NodeToClone
boolean $deep = >>true<<
Specifies whether to perform a deep clone or to clone only the current node.
Returns object DomNode

See Also cloneNode()

_internal_selfCheck

private boolean _internal_selfCheck( )

  _internal_selfCheck checks the current node, whether it is linked to a document or not!
This function is used internally to determine, whether a independent nodehas to be created. This is the case, when you add a new element to a node, whichis not yet attached to a parent node!

Returns boolean

true

See Also appendChild()

_internal_getNodeById

private object DomNode _internal_getNodeById( object DomNode $search, string $IdToSearch )

  _internal_getNodeById
This private functions performs the recursive scan through all child nodes for thecurrent node. This functions deals with >>DomNode<< Objects.

Parameter
object DomNode $search
string $IdToSearch
of the node to be retrieved
Returns object DomNode

The first node with the given id, false if not found!

Magic This functions works which >> DomNode << objects, never use directly!
See Also getNodeById()

Private Field Details

$nodeName

private string $nodeName

>>""<<

The Name of the Node.
The Name of the Node depending on it's type


$nodevalue

private string $nodevalue

>><<

The Value of the node, used as <tag> $nodevalue </tag>


$attribute

private array $attribute

>>array()<<

Array with all attributes for the node
This array will only be used, when the node is not yet attached to a document!


$node

private object DomNode $node

>><<

contains the DomNode Object



Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta