Back to FeedParser class

Method moveToNextElement

protected bool
moveToNextElement
(mixed $name = null)
Method to move the stream parser to the next XML element node.
Parameters
  • string $name The name of the element for which to move the stream forward until is found.
Returns
  • bool True if the stream parser is on an XML element node.
Since
  • 3.1.4
Class: FeedParser
Project: Joomla

Method moveToNextElement - Source code

/**
 * Method to move the stream parser to the next XML element node.
 *
 * @param   string  $name  The name of the element for which to move the stream forward until is found.
 *
 * @return  boolean  True if the stream parser is on an XML element node.
 *
 * @since   3.1.4
 */
protected function moveToNextElement($name = null)
{
    // Only keep looking until the end of the stream.
    while ($this->stream->read()) {
        // As soon as we get to the next ELEMENT node we are done.
        if ($this->stream->nodeType == \XMLReader::ELEMENT) {
            // If we are looking for a specific name make sure we have it.
            if (isset($name) && $this->stream->name != $name) {
                continue;
            }
            return true;
        }
    }
    return false;
}