_entityTag = $params['entity_tag']; if ( $params['xml_location'] ) $this->_xmlFilename = $params['xml_location']; if ( $params['extension'] ) $this->_extension = $params['extension']; $this->_entityTagPlural = $this->_entityTag . "s"; parent::__construct(); } protected function parseFile ( $filename ) { $this->_xmlObject = simplexml_load_file ( $filename ) ; if ( !$this->_xmlObject ) throw new Exception("Could not parse " . $this->_xmlFilename); if ( file_exists ( $filename . ".params" ) ) { $this->_params = json_decode(file_get_contents ( $filename . ".params"),true ); } // try to find all nodes in the document matching the tag $entities = $this->_xmlObject->xpath( "//" . $this->_entityTag ); if ( !$this->_parsedEntities ) $this->_parsedEntities = array(); $this->_parsedEntities = array_merge ( $this->_parsedEntities, $entities ); } public function readCustomNamespace ( $prefix, $object, $name ) { $tmp = $object->xpath("//".$prefix.":" . $name); return $tmp[0]; } public function parse() { if ( !$this->_xmlFilename ) throw new Exception("XML File is not specified."); if ( file_exists ( Mage::getBaseDir('base') . "/" . $this->_xmlFilename ) ) { $this->_xmlFilename = Mage::getBaseDir('base') . "/" . $this->_xmlFilename; } if ( is_dir ( $this->_xmlFilename ) ) { foreach ( glob ( $this->_xmlFilename . "/*" . $this->_extension ) as $filename ) { $this->parseFile( $filename ); $this->_processedFiles []= $filename; } } else { $this->parseFile( $this->_xmlFilename ); $this->_processedFiles []= $this->_xmlFilename; } return $this->_parsedEntities; } }