Your IP : 3.144.30.86
<?
class XmlParser
{
const IBLOCK_ID = 18;
protected $MIN_ID_FOR_INSERT = 100000000;
protected $MAIN_TAG = 'ExportedGateDictionary';
protected $INFO_TAGS = array('ID', 'Paren1tID', 'Code', 'Name', 'NameEn');
protected $DB = null;
protected $Context = array();
protected $object = array();
protected $inside_data = false;
protected $log = null;
protected $error_log = null;
protected $error_is_fetched = false;
protected function parseData($tag) {}
public function beginParsing() {}
public function endParsing() {}
function __construct(&$db, $log, $error_log) {
$this->DB = $db;
$this->log = $log;
$this->error_log = $error_log;
}
function tagOpen($parser, $name, $attrs) {
$len = count($this->Context);
array_push($this->Context, $name);
$this->inside_data = false;
}
function tagData($parser, $tagData) {
$len = count($this->Context);
if ($len > 1 && in_array($this->Context[$len - 1], $this->INFO_TAGS)
&& $this->Context[$len - 2] == $this->MAIN_TAG)
{
if ($this->inside_data)
$this->object[$this->Context[$len - 1]] .= $tagData;
else
$this->object[$this->Context[$len - 1]] = $tagData;
}
$this->inside_data = true;
}
function tagClosed($parser, $name) {
$this->inside_data = false;
if ($name == $this->MAIN_TAG)
{
$this->parseData($name);
unset($this->object);
}
array_pop($this->Context);
}
function param($name) {
return isset($this->object[$name]) ? $this->object[$name] : null;
}
public function message_to_log($msg) {
//print $msg."\r\n";
if ($this->log)
{
if ($msg[strlen($msg) - 1] != "\n")
$msg.="\r\n";
fputs($this->log, date("r", time()) . " " . $msg);
}
}
public function message_to_error_log($msg) {
$this->error_is_fetched = true;
if ($this->error_log)
{
if ($msg[strlen($msg) - 1] != "\n")
$msg.="\r\n";
fputs($this->error_log, date("r", time()) . " " . $msg);
}
$this->message_to_log($msg);
}
public function errorIsFetched() {
return $this->error_is_fetched;
}
}