You are here

public function XML2Array::parse in Opigno 7

File

modules/scorm/includes/XML2Array.php, line 15
Defines the XML2Array class, for easy XML manipulation. Based on http://ch2.php.net/xml_parse#52567.

Class

XML2Array
@file Defines the XML2Array class, for easy XML manipulation. Based on http://ch2.php.net/xml_parse#52567.

Code

public function parse($xlm_string) {
  $this->xml_parser = xml_parser_create();
  xml_set_object($this->xml_parser, $this);
  xml_set_element_handler($this->xml_parser, "tagOpen", "tagClosed");
  xml_set_character_data_handler($this->xml_parser, "tagData");
  $this->xml_string = xml_parse($this->xml_parser, $xlm_string);
  if (!$this->xml_string) {
    watchdog('opigno_scorm', sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->xml_parser)), xml_get_current_line_number($this->xml_parser)), array(), WATCHDOG_ERROR);
  }
  xml_parser_free($this->xml_parser);
  return $this->output;
}