24 require_once(
"./Services/Xml/classes/class.ilSaxParser.php");
58 $this->has_error =
false;
68 xml_set_object($a_xml_parser, $this);
69 xml_set_element_handler($a_xml_parser,
'handlerBeginTag',
'handlerEndTag');
70 xml_set_character_data_handler($a_xml_parser,
'handlerCharacterData');
78 parent::startParsing();
86 public function parse($a_xml_parser, $a_fp = null)
91 while (
$data = fread($a_fp, 4096)) {
92 $parseOk = xml_parse($a_xml_parser,
$data, feof($a_fp));
101 && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE)) {
102 $this->error_code = xml_get_error_code($a_xml_parser);
103 $this->error_line = xml_get_current_line_number($a_xml_parser);
104 $this->error_col = xml_get_current_column_number($a_xml_parser);
105 $this->error_msg = xml_error_string($a_xml_parser);
106 $this->has_error =
true;
118 $this->attributes += count($a_attribs);
134 $this->text_size += strlen($a_data);
159 return "Error: " . $this->error_msg .
" at line:" . $this->error_line .
" column:" .
$this->error_col;
__construct($a_xml_file='', $throwException=false)
Constructor.
parse($a_xml_parser, $a_fp=null)
parse xml file
setHandlers($a_xml_parser)
set event handler should be overwritten by inherited class private
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
startParsing()
start the parser
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
handlerEndTag($a_xml_parser, $a_name)
handler for end of element