- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/xml.php
- Класс: CXMLFileStream
- Вызов: CXMLFileStream::getXmlChunk
private function getXmlChunk()
{
if ($this->bufPosition >= $this->bufLen)
{
if (is_resource($this->fileHandler) && !feof($this->fileHandler))
{
$this->buf = fread($this->fileHandler, $this->readSize);
$this->bufPosition = 0;
$this->bufLen = strlen($this->buf);
}
else
{
return false;
}
}
//Skip line delimiters (ltrim)
$xml_position = strpos($this->buf, "<", $this->bufPosition);
while ($xml_position === $this->bufPosition)
{
$this->bufPosition++;
$this->filePosition++;
//Buffer ended with white space so we can refill it
if ($this->bufPosition >= $this->bufLen)
{
if (!feof($this->fileHandler))
{
$this->buf = fread($this->fileHandler, $this->readSize);
$this->bufPosition = 0;
$this->bufLen = strlen($this->buf);
}
else
{
return false;
}
}
$xml_position = strpos($this->buf, "<", $this->bufPosition);
}
//Let's find next line delimiter
while ($xml_position===false)
{
$next_search = $this->bufLen;
//Delimiter not in buffer so try to add more data to it
if (!feof($this->fileHandler))
{
$this->buf .= fread($this->fileHandler, $this->readSize);
$this->bufLen = strlen($this->buf);
}
else
{
break;
}
//Let's find xml tag start
$xml_position = strpos($this->buf, "<", $next_search);
}
if ($xml_position===false)
{
$xml_position = $this->bufLen+1;
}
$len = $xml_position-$this->bufPosition;
$this->filePosition += $len;
$result = substr($this->buf, $this->bufPosition, $len);
$this->bufPosition = $xml_position;
return $result;
}