/** * Functions / Methods */ function xml_read($xmlSource, $from_file = TRUE) { global $xpath; $xpath = NULL; $xmlOptions = array(XML_OPTION_CASE_FOLDING => FALSE, XML_OPTION_SKIP_WHITE => TRUE); $xpath = new XPath(FALSE, $xmlOptions); //$xpath->bDebugXmlParse = TRUE; if ($from_file) { if (file_exists($xmlSource) && is_readable($xmlSource)) { if (!$xpath->importFromFile($xmlSource)) { die('xml_read(): XPath error > ' . $xpath->getLastError()); } } else { die('xml_read(): Can\'t find or open: ' . realpath($xmlSource)); } } else { if (!empty($xmlSource)) { if (!$xpath->importFromString($xmlSource)) { die('xml_read(): XPath error > ' . $xpath->getLastError()); } } else { die('xml_read(): Given source is empty in line.'); } } return true; }