eZDOMNode Class Reference
[XML parser and DOM library]

eZDOMNode encapsulates XML DOM nodes More...

List of all members.

Public Member Functions

 append_child (&$node)
 appendAttribute (&$node)
 appendAttributes ($attributeValues, $attributeDefinitions, $includeEmptyValues=false)
 appendChild (&$node)
 attributeCount ()
attributes ()
attributesNS ($namespaceURI)
 attributeValue ($attributeName)
 attributeValueNS ($attributeName, $namespaceURI)
 attributeValues ($attributeDefinitions=false, $defaultValue=null)
children ()
 childrenCount ()
 cleanup (&$node)
 clone ()
 collectTextContent (&$element)
content ()
 debugNode (&$node, $showAttributes, $showParent)
 dump_mem ($format, $charset=false)
 elementAttributeValueByName ($name, $attributeName)
elementByAttributeValue ($attr, $value)
elementByName ($name)
elementChildrenByName ($name)
elementFirstChildByName ($name)
elementsByName ($name)
elementsTextContentByName ($name)
 elementTextContentByName ($name)
 eZDOMNode ()
 first_child ()
firstChild ()
 get_attribute ($attributeName)
 get_elements_by_tagname ($name)
 getAttribute ($attributeName)
 getAttributeNS ($namespaceURI, $localName)
 hasAttributes ()
 hasChildNodes ()
 hasChildren ()
 insertBefore (&$newNode, &$refNode)
lastChild ()
 localName ()
 name ()
 namespaceURI ()
nextSibling ()
 node_value ()
 prefix ()
previousSibling ()
 remove_attribute ($name)
 removeAttribute ($name)
 removeAttributeNS ($namespaceURI, $localName)
 removeAttributes ()
 removeChild (&$childToRemove)
 removeChildren ()
 removeLastChild ()
 removeNamedAttribute ($name)
 removeNamedChildren ($name)
 replaceChild (&$newChild, &$oldChild)
 set_attribute ($name, $value)
 setAttribute ($name, $value)
 setAttributeNS ($namespaceURI, $qualifiedName, $value)
 setContent ($content)
 setName ($name)
 setNamespaceURI ($uri)
 setPrefix ($value)
 setType ($type)
 textContent ()
 toString ($level, $charset=false, $convertSpecialChars=true)
 type ()
 writeDebug (&$node, $text, $showAttributes=false, $showParent=false)
 writeDebugStr (&$node, $text)

Private Attributes

 $Attributes = array()
 Attributes.
 $Children = array()
 Subnodes.
 $Content = ""
 $content = ""
 Content of the node.
 $flag = false
 $LocalName = false
 The local part of a name. E.g: book:title, title is the local part.
 $Name = false
 $NamespaceURI = false
 Contains the namespace URI. E.g. xmlns="http://ez.no/article/", http://ez.no/article/ would be the namespace URI.
 $nodeName = null
 DOM W3C compatibility.
 $parentNode = false
 $Prefix = false
 contains the namespace prefix. E.g: book:title, book is the prefix
 $tagname = null
 tagname, added for DOM XML compatibility.
 $Type = EZ_XML_NODE_ELEMENT
 $type
 Type of the DOM node. ElementNode=1, AttributeNode=2, TextNode=3, CDATASectionNode=4.
 $value = ''

Detailed Description

eZDOMNode encapsulates XML DOM nodes

The following node types are supported:

See also:
eZXML eZDOMDocument

Definition at line 66 of file ezdomnode.php.


Member Function Documentation

eZDOMNode::append_child ( &$  node  ) 

Alias for libXML compatibility

Definition at line 652 of file ezdomnode.php.

eZDOMNode::appendAttribute ( &$  node  ) 

Appends the attribute node $node as an attribute of the current node.

Returns:
The attribute node that was just inserted or false if it failed to insert an attribute.
Note:
This will only make sense for element nodes.

Definition at line 664 of file ezdomnode.php.

Referenced by set_attribute(), setAttribute(), and setAttributeNS().

eZDOMNode::appendAttributes ( attributeValues,
attributeDefinitions,
includeEmptyValues = false 
)

Appends multiple attributes and attribute values.

Parameters:
$attributeValues An associative array containing the attribute values to insert, it maps from lookup name to attribute value.
$attributeDefinitions An associative array defining how lookup names maps to attribute names, the array key is the attribute name and the array value the lookup name.
$includeEmptyValues If true it will set attribute values even though they don't exist in $attributeValues
      $definition = array( 'name' => 'song_name',
                           'track' => 'track_name' );
      $values = array( 'song_name' => 'Shine On You Crazy Diamond',
                       'track_number' => '1' );
      $node->appendAttributes( $values, $definition );
      \encode

      The node will then look like.
      \code
      <song name="Shine On You Crazy Diamond" track="1" />

This method and attributeValues() work together, the returned result of attributeValues() can be inserted with this method.

Note:
This will only make sense for element nodes.
See also:
attributeValues

Definition at line 708 of file ezdomnode.php.

eZDOMNode::appendChild ( &$  node  ) 

Appends the node $node as a child of the current node.

Returns:
The node that was just inserted or false if it failed to insert a node.
Note:
This will only make sense for element nodes.

Definition at line 636 of file ezdomnode.php.

Referenced by append_child().

eZDOMNode::attributeCount (  ) 
Returns:
The number of attributes for the node.
Note:
This will only make sense for element nodes.

Definition at line 272 of file ezdomnode.php.

& eZDOMNode::attributes (  ) 
Returns:
An array with attribute nodes.
Note:
This will only make sense for element nodes.

Definition at line 230 of file ezdomnode.php.

& eZDOMNode::attributesNS ( namespaceURI  ) 
Returns:
An array with attribute nodes matching the namespace URI $namespaceURI.
Note:
This will only make sense for element nodes.

Definition at line 240 of file ezdomnode.php.

eZDOMNode::attributeValue ( attributeName  ) 
Deprecated:
This function is deprecated. Use getAttribute instead.
Returns:
The value of the attribute named $attributeName. If no value is found false is returned.
Note:
This will only make sense for element nodes.

Definition at line 497 of file ezdomnode.php.

Referenced by get_attribute().

eZDOMNode::attributeValueNS ( attributeName,
namespaceURI 
)
Deprecated:
This function is deprecated. Use getAttributeNS instead.
Returns:
The value of the attribute named $attributeName and having namespace $namespaceURI. If no value is found false is returned.
Note:
This will only make sense for element nodes.

Definition at line 610 of file ezdomnode.php.

eZDOMNode::attributeValues ( attributeDefinitions = false,
defaultValue = null 
)

Goes trough all attributes of the node and matches the attribute names with the parameter $attributeDefinitions.

Parameters:
$attributeDefinitions An associative array which maps from matching attribute name to lookup name.
$defaultValue If other value than null it will be set as value for all lookup names that didn't match

The matching attribute name in the will be matched against the attributes of the node. When a match is found the attribute value will be fetched and placed in the returned associative array using lookup name as key.

A code example will explain this, the variable $songNode contains the following xml

      <song name="Shine On You Crazy Diamond" track="1" />

The PHP code is.

      $def = array( 'name' => 'song_name',
                    'track' => 'track_number' );
      $values = $songNode->attributeValues( $def );
      \encode

      \a $values will now contain.
      \code
      array( 'song_name' => 'Shine On You Crazy Diamond',
             'track_number => '1' )

This method and appendAttributes() work together, the values inserted with appendAttributes() can be extracted with this method.

Note:
This will only make sense for element nodes.
See also:
elementAttributeValueByName, appendAttributes

Definition at line 569 of file ezdomnode.php.

& eZDOMNode::children (  ) 
Returns:
An array with child nodes.
Note:
This will only make sense for element nodes.

Definition at line 282 of file ezdomnode.php.

eZDOMNode::childrenCount (  ) 
Returns:
The number of children for the node.
Note:
This will only make sense for element nodes.

Definition at line 302 of file ezdomnode.php.

eZDOMNode::cleanup ( &$  node  ) 

Subtree destructor. Needed to clean memory properly.

Definition at line 100 of file ezdomnode.php.

eZDOMNode::clone (  ) 

Makes a copy of the current node and returns a reference to it.

Definition at line 83 of file ezdomnode.php.

eZDOMNode::collectTextContent ( &$  element  ) 

Definition at line 863 of file ezdomnode.php.

Referenced by textContent().

& eZDOMNode::content (  ) 
Returns:
The content of the node or false if it does not contain any content.
Note:
This will only make sense for text and CDATA nodes.

Definition at line 210 of file ezdomnode.php.

Referenced by eZDOMNode().

eZDOMNode::debugNode ( &$  node,
showAttributes,
showParent 
)

Definition at line 1333 of file ezdomnode.php.

Referenced by writeDebug().

eZDOMNode::dump_mem ( format,
charset = false 
)

Alias for libxml compatibility

Definition at line 1026 of file ezdomnode.php.

eZDOMNode::elementAttributeValueByName ( name,
attributeName 
)

Finds the first element named $name and returns the value of the attribute named $attributeName. If no element node is found or no attribute with the given name exists it returns false.

Note:
This will only make sense for element nodes.
If multiple elements with that name is found false is returned.
See also:
elementByName, attributeValue

Definition at line 525 of file ezdomnode.php.

& eZDOMNode::elementByAttributeValue ( attr,
value 
)
Parameters:
attribute name
attribute value
Returns:
element by attribute value

Definition at line 432 of file ezdomnode.php.

& eZDOMNode::elementByName ( name  ) 
Returns:
The first element that is named $name. If multiple elements with that name is found false is returned.
Note:
This will only make sense for element nodes.
See also:
elementsByName

Definition at line 372 of file ezdomnode.php.

Referenced by elementAttributeValueByName(), elementChildrenByName(), elementFirstChildByName(), and elementTextContentByName().

& eZDOMNode::elementChildrenByName ( name  ) 

Finds the first element named $name and returns the children of that node. If no element node is found it returns false.

Note:
This will only make sense for element nodes.
If multiple elements with that name is found false is returned.
See also:
elementByName, children

Definition at line 335 of file ezdomnode.php.

& eZDOMNode::elementFirstChildByName ( name  ) 

Finds the first element named $name and returns the first child of that node. If no element node is found or there are not children it returns false.

Note:
This will only make sense for element nodes.
If multiple elements with that name is found false is returned.
See also:
elementByName, firstChild

Definition at line 354 of file ezdomnode.php.

& eZDOMNode::elementsByName ( name  ) 
Returns:
An array with elements that matches the name $name.
Note:
This will only make sense for element nodes.
See also:
elementByName

Definition at line 454 of file ezdomnode.php.

& eZDOMNode::elementsTextContentByName ( name  ) 
Returns:
An array with text contents taken from all child nodes which matches the name $name.
Note:
This will only make sense for element nodes.
See also:
elementsByName, textContent

Definition at line 474 of file ezdomnode.php.

eZDOMNode::elementTextContentByName ( name  ) 

Finds the first element named $name and returns the text content of that node. If no element node is found or no text content exists it returns false.

Note:
This will only make sense for element nodes.
If multiple elements with that name is found false is returned.
See also:
elementByName, textContent

Definition at line 415 of file ezdomnode.php.

eZDOMNode::eZDOMNode (  ) 

Initializes the DOM node.

Definition at line 71 of file ezdomnode.php.

Referenced by clone().

eZDOMNode::first_child (  ) 
Returns:
first child of current dom node.
Note:
added for compatibility with DOM XML library

Definition at line 312 of file ezdomnode.php.

& eZDOMNode::firstChild (  ) 
Returns:
The first child of the node or false if there are no children.
Note:
This will only make sense for element nodes.
W3C DOM function

Definition at line 1147 of file ezdomnode.php.

eZDOMNode::get_attribute ( attributeName  ) 

Alias for libxml compatibility

Definition at line 512 of file ezdomnode.php.

eZDOMNode::get_elements_by_tagname ( name  ) 

Alias for libxml compatibility

Definition at line 394 of file ezdomnode.php.

eZDOMNode::getAttribute ( attributeName  ) 

Definition at line 1075 of file ezdomnode.php.

eZDOMNode::getAttributeNS ( namespaceURI,
localName 
)

Definition at line 1088 of file ezdomnode.php.

eZDOMNode::hasAttributes (  ) 
Returns:
true if the node has any attributes.
Note:
This will only make sense for element nodes.

Definition at line 262 of file ezdomnode.php.

eZDOMNode::hasChildNodes (  ) 

Definition at line 1135 of file ezdomnode.php.

eZDOMNode::hasChildren (  ) 
Returns:
true if the node has children.
Note:
This will only make sense for element nodes.

Definition at line 292 of file ezdomnode.php.

eZDOMNode::insertBefore ( &$  newNode,
&$  refNode 
)

Replaces child by the new one given.

Note:
W3C DOM function

Definition at line 1222 of file ezdomnode.php.

& eZDOMNode::lastChild (  ) 
Returns:
The last child node or false if there are no children.
Note:
This will only make sense for element nodes.

Definition at line 1167 of file ezdomnode.php.

eZDOMNode::localName (  ) 

Returns the local name of the node if the node uses namespaces. If not false is returned.

Definition at line 156 of file ezdomnode.php.

eZDOMNode::name (  ) 
Returns:
The name of the node.

For element and attributes nodes this will the name supplied when creating the node, for text nodes it returns text and CDATA returns cdata-section

Definition at line 123 of file ezdomnode.php.

Referenced by removeAttribute(), removeNamedAttribute(), and removeNamedChildren().

eZDOMNode::namespaceURI (  ) 
Returns:
The namespace URI for the node or false if no URI

Definition at line 140 of file ezdomnode.php.

Referenced by toString().

& eZDOMNode::nextSibling (  ) 
Note:
emulation of W3C DOM property

Definition at line 1249 of file ezdomnode.php.

eZDOMNode::node_value (  ) 
Returns:
node value of current dom node.
Note:
added for compatibility with DOM XML library

Definition at line 322 of file ezdomnode.php.

eZDOMNode::prefix (  ) 
Returns:
The prefix of the nodes name, this will be the namespace for the node.

Definition at line 164 of file ezdomnode.php.

Referenced by toString().

& eZDOMNode::previousSibling (  ) 
Note:
emulation of W3C DOM property

Definition at line 1282 of file ezdomnode.php.

eZDOMNode::remove_attribute ( name  ) 

Alias for libxml compatibility

Definition at line 750 of file ezdomnode.php.

eZDOMNode::removeAttribute ( name  ) 

Definition at line 1102 of file ezdomnode.php.

eZDOMNode::removeAttributeNS ( namespaceURI,
localName 
)

Definition at line 1117 of file ezdomnode.php.

eZDOMNode::removeAttributes (  ) 

Removes all attribute from the node.

Note:
This will only make sense for element nodes.

Definition at line 760 of file ezdomnode.php.

eZDOMNode::removeChild ( &$  childToRemove  ) 

Removes child by the given child object.

Note:
W3C DOM function

Definition at line 832 of file ezdomnode.php.

eZDOMNode::removeChildren (  ) 

Removes all child nodes from the current node.

Note:
This will only make sense for element nodes.

Definition at line 795 of file ezdomnode.php.

eZDOMNode::removeLastChild (  ) 

Removes the last child node of the current node.

Note:
This will only make sense for element nodes.

Definition at line 814 of file ezdomnode.php.

eZDOMNode::removeNamedAttribute ( name  ) 

Removes the attribute node named $name.

Returns:
The removed attribute node or false if no such node exists.
Note:
This will only make sense for element nodes.

Definition at line 733 of file ezdomnode.php.

Referenced by remove_attribute(), and set_attribute().

eZDOMNode::removeNamedChildren ( name  ) 

Removes all child nodes that matches the name $name.

Returns:
true if it removed any nodes, otherwise false.
Note:
This will only make sense for element nodes.

Definition at line 771 of file ezdomnode.php.

eZDOMNode::replaceChild ( &$  newChild,
&$  oldChild 
)

Replaces child by the new one given.

Note:
W3C DOM function

Definition at line 1186 of file ezdomnode.php.

eZDOMNode::set_attribute ( name,
value 
)

Definition at line 674 of file ezdomnode.php.

eZDOMNode::setAttribute ( name,
value 
)

Definition at line 1037 of file ezdomnode.php.

eZDOMNode::setAttributeNS ( namespaceURI,
qualifiedName,
value 
)

Definition at line 1055 of file ezdomnode.php.

eZDOMNode::setContent ( content  ) 

Sets the content of the node to the $content.

Note:
This will only make sense for text and CDATA nodes.

Definition at line 220 of file ezdomnode.php.

eZDOMNode::setName ( name  ) 

Sets the current name to $name.

Definition at line 131 of file ezdomnode.php.

eZDOMNode::setNamespaceURI ( uri  ) 

Sets the namespace URI of the node to $uri.

Definition at line 148 of file ezdomnode.php.

eZDOMNode::setPrefix ( value  ) 

Sets the namespace prefix for this node to $value.

Definition at line 172 of file ezdomnode.php.

eZDOMNode::setType ( type  ) 

Sets the node type to $type.

Use one of the following defines for the type:

  • EZ_XML_NODE_ELEMENT - Element nodes
  • EZ_XML_NODE_ATTRIBUTE - Attribute nodes
  • EZ_XML_NODE_TEXT - Text nodes
  • EZ_XML_NODE_CDATASECTION - CDATA nodes

Definition at line 200 of file ezdomnode.php.

eZDOMNode::textContent (  ) 
Returns:
The content() of the first child node or false if there are no children.
Note:
This will only make sense for element nodes.
See also:
elementTextContentByName

Definition at line 858 of file ezdomnode.php.

eZDOMNode::toString ( level,
charset = false,
convertSpecialChars = true 
)
Returns:
A string that represents the current node. The string will be created according to the node type which are:
  • Element node, places the name in <>, expands all attributes and calls toString() on all children.
  • Text node, returns the content() by escaping the characters & < > ' and ".
  • CDATA node, returns the text wrapped in <![CDATA[ and ]]
Parameters:
$level The current tab level, starts at 0 and is increased by 1 for each recursion
$charset Which charset the text will be encoded in, currently not used

Example strings.

      '<song name="Shine On You Crazy Diamond" track="1" />'
      'This &amp; that &quot;wrapped&quot; in &lt;div&gt; tags'
      '<![CDATA[This & that "wrapped" in <div> tags'
Note:
This will only make sense for element nodes.

Definition at line 904 of file ezdomnode.php.

Referenced by dump_mem().

eZDOMNode::type (  ) 
Returns:
An integer value which describes the type of node.

The type is one of:

  • 1 - Element node, that is a node which contains attributes and children.
  • 2 - Attribute node, this is a node which contains a name and a value.
  • 3 - Text node, this is a node which contains a text string
  • 4 - CDATA node, this is a node which contains a text string

Definition at line 186 of file ezdomnode.php.

Referenced by eZDOMNode().

eZDOMNode::writeDebug ( &$  node,
text,
showAttributes = false,
showParent = false 
)

Outputs DOM subtree to the debug output in the easy readable form.

Parameters:
node subtree root node

Definition at line 1312 of file ezdomnode.php.

Referenced by writeDebugStr().

eZDOMNode::writeDebugStr ( &$  node,
text 
)

Outputs XML from DOM as a string.

Parameters:
node subtree root node

Definition at line 1370 of file ezdomnode.php.


Member Data Documentation

eZDOMNode::$Attributes = array() [private]

Attributes.

Definition at line 1402 of file ezdomnode.php.

eZDOMNode::$Children = array() [private]

Subnodes.

Definition at line 1399 of file ezdomnode.php.

eZDOMNode::$Content = "" [private]

Definition at line 1395 of file ezdomnode.php.

eZDOMNode::$content = "" [private]

Content of the node.

Definition at line 1394 of file ezdomnode.php.

Referenced by setContent().

eZDOMNode::$flag = false [private]

Definition at line 1419 of file ezdomnode.php.

eZDOMNode::$LocalName = false [private]

The local part of a name. E.g: book:title, title is the local part.

Definition at line 1408 of file ezdomnode.php.

eZDOMNode::$Name = false [private]

Name of the node

Definition at line 1381 of file ezdomnode.php.

eZDOMNode::$NamespaceURI = false [private]

Contains the namespace URI. E.g. xmlns="http://ez.no/article/", http://ez.no/article/ would be the namespace URI.

Definition at line 1405 of file ezdomnode.php.

eZDOMNode::$nodeName = null [private]

DOM W3C compatibility.

Definition at line 1387 of file ezdomnode.php.

eZDOMNode::$parentNode = false [private]

Reference to the parent node. Available only if Document has been created with parameter $setParentNode = true or parsed with eZXML::domTree function with $params["SetParentNode"] = true

Definition at line 1416 of file ezdomnode.php.

eZDOMNode::$Prefix = false [private]

contains the namespace prefix. E.g: book:title, book is the prefix

Definition at line 1411 of file ezdomnode.php.

eZDOMNode::$tagname = null [private]

tagname, added for DOM XML compatibility.

Definition at line 1384 of file ezdomnode.php.

eZDOMNode::$Type = EZ_XML_NODE_ELEMENT [private]

Definition at line 1391 of file ezdomnode.php.

eZDOMNode::$type [private]

Type of the DOM node. ElementNode=1, AttributeNode=2, TextNode=3, CDATASectionNode=4.

Definition at line 1390 of file ezdomnode.php.

Referenced by setType().

eZDOMNode::$value = '' [private]

The documentation for this class was generated from the following file:
Generated on Mon Jul 12 07:10:26 2010 for eZ publish by  doxygen 1.6.3