public function XMLBasedConstruct($xml, $wdtParameters = array()) { if (!$xml) { throw new WDTException('File you provided cannot be found.'); } if (strpos($xml, '.xml') === false) { throw new WDTException('Non-XML file provided!'); } $XMLObject = simplexml_load_file($xml); $XMLObject = apply_filters('wpdatatables_filter_simplexml', $XMLObject, $this->getWpId()); $XMLArray = WDTTools::convertXMLtoArr($XMLObject); foreach ($XMLArray as &$xml_el) { if (is_array($xml_el) && array_key_exists('attributes', $xml_el)) { $xml_el = $xml_el['attributes']; } } return $this->arrayBasedConstruct($XMLArray, $wdtParameters); }
public function XMLBasedConstruct($xml, $wdtParameters = array()) { if (!$xml) { throw new WDTException('File you provided cannot be found.'); } if (strpos($xml, '.xml') === false) { throw new WDTException('Non-XML file provided!'); } // checking if the table is existing in cache // and setting the flag if it does if (self::$mc) { $this->_cacheHash = 'bbxml_' . md5($xml); if (@self::$mc->get($this->_cacheHash)) { $this->_fromCache = $this->_cacheHash; return true; } } $XMLObject = simplexml_load_file($xml); $XMLObject = apply_filters('wpdatatables_filter_simplexml', $XMLObject, $this->getWpId()); $XMLArray = WDTTools::convertXMLtoArr($XMLObject); while (is_array($XMLArray) && count($XMLArray) == 1) { $XMLArray = $XMLArray[key($XMLArray)]; } foreach ($XMLArray as &$xml_el) { if (is_array($xml_el) && array_key_exists('attributes', $xml_el)) { $xml_el = $xml_el['attributes']; } } return $this->arrayBasedConstruct($XMLArray, $wdtParameters); }