/**
  * Add an element to elements array
  *
  * @access  private
  * @param	String	Name of the group of tag.
  * @param 	String  'type' attibute for this tag.
  * @param 	String  'mode' attibute for this tag.
  * @param 	String  'unit' attibute for this tag.
  * @param	Array   Array of data for this tag element.
  * @param 	String  'priority' attibute for this tag.
  * @param 	String  'limit' attribute to restrict recurent type occuencies in Date or Price objects.
  * @param 	String  'interval' attribute.
  * @param 	String  'selected_day' attribute.
  * @param 	String 	'selected_week' attribute.
  * @return	void
  */
 private function addElement($groupName, $type = '', $mode = '', $unit = NULL, $data_ = NULL, $priority = 0, $limit = 0, $interval = 1, $selected_day = NULL, $selected_week = NULL, $moving_position = NULL)
 {
     $groupName = strtolower($groupName);
     $errorType = 'Error[' . $groupName . ']: ';
     if (strlen($type) > 0) {
         if (count($data_) > 0) {
             if ($this->controlType($groupName, $type) == TRUE) {
                 if ($this->controlMode($groupName, $mode) == TRUE) {
                     if ($this->controlSelectedDay($groupName, $selected_day) == TRUE) {
                         if ($this->controlSelectedWeek($groupName, $selected_week) == TRUE) {
                             if ($this->controlTags($groupName, $data_) == TRUE) {
                                 foreach ($data_ as $tag => $value) {
                                     if ($this->controlNodeContent($tag, $value) == FALSE) {
                                         throw new Exception($errorType . "The XML element < {$tag} > have an invalid content: '{$value}', please control the correct syntax in ESS DTD.");
                                         break;
                                     }
                                 }
                                 array_push($this->elements[$groupName], array('type' => FeedValidator::charsetString($type, $this->CHARSET), 'mode' => FeedValidator::charsetString($mode, $this->CHARSET), 'unit' => FeedValidator::charsetString($unit, $this->CHARSET), 'priority' => FeedValidator::charsetString($priority, $this->CHARSET), 'limit' => FeedValidator::charsetString($limit, $this->CHARSET), 'interval' => FeedValidator::charsetString($interval, $this->CHARSET), 'selected_day' => FeedValidator::charsetString($selected_day, $this->CHARSET), 'selected_week' => FeedValidator::charsetString($selected_week, $this->CHARSET), 'moving_position' => FeedValidator::charsetString($moving_position, $this->CHARSET), 'content' => array_filter(array_unique($data_))));
                             } else {
                                 $mandatories = "";
                                 foreach ($this->feedDTD[$groupName]['tags'] as $tag => $mandatory) {
                                     if ($mandatory == TRUE && strlen($data_[$tag]) <= 0) {
                                         $mandatories .= "< " . $tag . " > ";
                                     }
                                 }
                                 if (FeedValidator::isNull($mandatories) == FALSE) {
                                     throw new Exception($errorType . "All the mandatories XML sub-elements of < {$groupName} > are not provided (" . $mandatories . ").");
                                 }
                             }
                         } else {
                             throw new Exception($errorType . "Attribute selected_week='" . $selected_week . "' is not available in ESS DTD.");
                         }
                     } else {
                         throw new Exception($errorType . "Attribute selected_day='" . $selected_day . "' is not available in ESS DTD.");
                     }
                 } else {
                     throw new Exception($errorType . "Attribute mode='" . $mode . "' is not available in ESS DTD.");
                 }
             } else {
                 throw new Exception($errorType . "Attribute type='" . $type . "' is not available in ESS DTD.");
             }
         } else {
             throw new Exception($errorType . "Element could not be empty.");
         }
     } else {
         throw new Exception($errorType . "The 'type' attribute is required.");
     }
 }