Back to Update class

Method _startElement

public void
_startElement
(mixed $parser, mixed $name, mixed $attrs = array())
XML Start Element callback
Parameters
  • object $parser Parser object
  • string $name Name of the tag found
  • array $attrs Attributes of the tag
Returns
  • void
Since
  • 1.7.0
-
  • This is public because it is called externally
Class: Update
Project: Joomla

Method _startElement - Source code

/**
 * XML Start Element callback
 *
 * @param   object  $parser  Parser object
 * @param   string  $name    Name of the tag found
 * @param   array   $attrs   Attributes of the tag
 *
 * @return  void
 *
 * @note    This is public because it is called externally
 * @since   1.7.0
 */
public function _startElement($parser, $name, $attrs = array())
{
    $this->stack[] = $name;
    $tag = $this->_getStackLocation();
    // Reset the data
    if (isset($this->{$tag})) {
        $this->{$tag}->_data = '';
    }
    switch ($name) {
        // This is a new update; create a current update
        case 'UPDATE':
            $this->currentUpdate = new \stdClass();
            break;
        // Handle the array of download sources
        case 'DOWNLOADSOURCE':
            $source = new DownloadSource();
            foreach ($attrs as $key => $data) {
                $key = strtolower($key);
                $source->{$key} = $data;
            }
            $this->downloadSources[] = $source;
            break;
        // Don't do anything
        case 'UPDATES':
            break;
        // For everything else there's...the default!
        default:
            $name = strtolower($name);
            if (!isset($this->currentUpdate->{$name})) {
                $this->currentUpdate->{$name} = new \stdClass();
            }
            $this->currentUpdate->{$name}->_data = '';
            foreach ($attrs as $key => $data) {
                $key = strtolower($key);
                $this->currentUpdate->{$name}->{$key} = $data;
            }
            break;
    }
}