- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/xml.php
- Класс: CXMLFileStream
- Вызов: CXMLFileStream::startElement
private function startElement($xmlChunk, $origChunk)
{
static $search = array(
"'&(quot|#34);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(amp|#38);'i",
);
static $replace = array(
""",
"<",
">",
"&",
);
$p = mb_strpos($xmlChunk, ">");
if ($p !== false)
{
if (mb_substr($xmlChunk, $p - 1, 1) == "/")
{
$elementName = mb_substr($xmlChunk, 0, $p - 1);
}
else
{
$elementName = mb_substr($xmlChunk, 0, $p);
}
if (($ps = mb_strpos($elementName, " "))!==false)
{
$elementAttrs = mb_substr($elementName, $ps + 1);
$elementName = mb_substr($elementName, 0, $ps);
}
else
{
$elementAttrs = "";
}
$this->elementStack[] = $elementName;
$this->positionStack[] = $this->filePosition - strlen($origChunk) - 1;
if (isset($this->endNodes[$elementName]))
{
$xmlPath = implode("/", $this->elementStack);
if (isset($this->elementHandlers[$xmlPath]))
{
$attributes = array();
if ($elementAttrs !== "")
{
preg_match_all("/(\S+)\s*=\s*"(.*?)"/s", $elementAttrs, $attrs_tmp);
if (strpos($elementAttrs, "&") === false)
{
foreach ($attrs_tmp[1] as $i=>$attrs_tmp_1)
{
$attributes[$attrs_tmp_1] = $attrs_tmp[2][$i];
}
}
else
{
foreach ($attrs_tmp[1] as $i=>$attrs_tmp_1)
{
$attributes[$attrs_tmp_1] = preg_replace($search, $replace, $attrs_tmp[2][$i]);
}
}
}
foreach ($this->elementHandlers[$xmlPath] as $callableHandler)
{
call_user_func_array($callableHandler, array(
$xmlPath,
$attributes,
));
}
}
}
}
}