ElementCreator Class Reference

Inheritance diagram for ElementCreator:

AtElementCreator DotElementCreator ExtractingElementCreator LinkElementCreator List of all members.

Detailed Description

Instances of this class serves for creating XML elements.

To be exact, you can create any DOMNode descendant in this class descendants.

Definition at line 50 of file xmlutils.php.

Public Member Functions

 __construct ($name, $attrs=NULL)
 create_element ($doc, $content=NULL)
 Call this to get new XML element.

Protected Attributes

 $attrs = array()
 Element's attributes.
 $name
 Element's name.


Member Function Documentation

ElementCreator::__construct name,
attrs = NULL
 

Parameters:
[in] $name Elements name.
[in] $attrs Array of attributes or NULL. Keys are used as attribute names, values as their values.

Definition at line 64 of file xmlutils.php.

References $attrs, and $name.

00064                                                {
00065       $this->name = $name;
00066       if ($attrs):
00067         $this->attrs = $attrs;
00068       endif;
00069     }

ElementCreator::create_element doc,
content = NULL
 

Call this to get new XML element.

By default it creates a DOMElement but descendants can return arbitrary DOMNode descendant.

Parameters:
[in] $doc DOMDocument instance.
[in] $content String with element's content or NULL.
Returns:
DOMElement instance or other DOMNode descendant in descendants of this class.

Reimplemented in LinkElementCreator, and ExtractingElementCreator.

Definition at line 82 of file xmlutils.php.

00082                                                    {
00083       $elem = $doc->createElement($this->name);
00084       foreach ($this->attrs as $name => $value):
00085         $elem->setAttribute($name, $value);
00086       endforeach;
00087       if ($content):
00088         $contentNode = $doc->createTextNode($content);
00089         $elem->appendChild($contentNode);
00090       endif;
00091       return $elem;
00092     }


Member Data Documentation

ElementCreator::$attrs = array() [protected]
 

Element's attributes.

Keys are used as attribute names, values as their values.

Definition at line 57 of file xmlutils.php.

Referenced by __construct().

ElementCreator::$name [protected]
 

Element's name.

Definition at line 53 of file xmlutils.php.

Referenced by __construct().


The documentation for this class was generated from the following file:
Generated on Sat Sep 24 01:26:43 2005 for Easy PHP Framework by  doxygen 1.4.2