/** * parse xml file into iCalcreator instance * * @author Kjell-Inge Gustafsson, kigkonsult <*****@*****.**> * @since 2.11.2 - 2012-01-20 * @param string $xmlfile * @param array$iCalcfg iCalcreator config array (opt) * @return mixediCalcreator instance or FALSE on error */ function &XMLfile2iCal($xmlfile, $iCalcfg = array()) { libxml_use_internal_errors(TRUE); $xml = simplexml_load_file($xmlfile); if (!$xml) { $str = ''; foreach (libxml_get_errors() as $error) { switch ($error->level) { case LIBXML_ERR_FATAL: $str .= 'FATAL '; break; case LIBXML_ERR_ERROR: $str .= 'ERROR '; break; case LIBXML_ERR_WARNING: default: $str .= 'WARNING '; break; } $str .= 'Failed loading XML' . PHP_EOL; if (!empty($error->file)) { $str .= ' file:' . $error->file . ', '; } $str .= 'line:' . $error->line . PHP_EOL; $str .= '(' . $error->code . ') ' . $error->message . PHP_EOL; } error_log($str); if (LIBXML_ERR_WARNING != $error->level) { return FALSE; } libxml_clear_errors(); } return xml2iCal($xml, $iCalcfg); }
/** * parse xml file into iCalcreator instance * * @author Kjell-Inge Gustafsson, kigkonsult <*****@*****.**> * @since 2.16.22 - 2013-06-18 * @param string $xmlfile * @param array $iCalcfg iCalcreator config array (opt) * @return mixediCalcreator instance or FALSE on error */ function XMLfile2iCal($xmlfile, $iCalcfg = array()) { if (FALSE === ($xmlstr = file_get_contents($xmlfile))) { return FALSE; } return xml2iCal($xmlstr, $iCalcfg); }