/**
* Method to move the stream parser to the closing XML node of the current element.
*
* @return void
*
* @since 3.1.4
* @throws \RuntimeException If the closing tag cannot be found.
*/
protected function moveToClosingElement()
{
// If we are on a self-closing tag then there is nothing to do.
if ($this->stream->isEmptyElement) {
return;
}
// Get the name and depth for the current node so that we can match the closing node.
$name = $this->stream->name;
$depth = $this->stream->depth;
// Only keep looking until the end of the stream.
while ($this->stream->read()) {
// If we have an END_ELEMENT node with the same name and depth as the node we started with we have a bingo. :-)
if ($this->stream->name == $name && $this->stream->depth == $depth && $this->stream->nodeType == \XMLReader::END_ELEMENT) {
return;
}
}
throw new \RuntimeException('Unable to find the closing XML node.');
}