示例#1
0
echo "<strong>Before unset</strong>";
debug($all_xml_files);
//Find template files to remove.
$n = array_search('allprops.xml', $all_xml_files);
$n1 = array_search('merge_template.xml', $all_xml_files);
//Remove template files
unset($all_xml_files[$n]);
unset($all_xml_files[$n1]);
//Show final array to be merged.
echo "<strong>After unset</strong>";
$all_xml_files = array_values($all_xml_files);
debug($all_xml_files);
//Loops through files in the folder
for ($i = 0; $i < sizeof($all_xml_files); $i++) {
    if (isset($all_xml_files[$i]) && strlen($all_xml_files[$i]) > 0) {
        //Get file and set up xml
        $xmlstr = file_get_contents($all_xml_files[$i]);
        $stock_xml = new SimpleXMLElement($xmlstr);
        $xmlstr = file_get_contents('allprops.xml');
        $xml_app = new SimpleXMLElement($xmlstr);
        //Adds the data to all props
        simplexml_merge($stock_xml, $xml_app);
        simplexml_mergeRental($stock_xml, $xml_app);
        simplexml_mergeLand($stock_xml, $xml_app);
        file_put_contents("allprops.xml", $stock_xml->asXML());
        rename($all_xml_files[$i], 'merged/' . $all_xml_files[$i]);
    }
}
echo "<h3>Final File</h3>";
$xml_debug = new SimpleXMLElement(file_get_contents('allprops.xml'));
debug($xml_debug);
示例#2
0
文件: Registry.php 项目: ssrsfs/blg
 private function _initializeRegistry()
 {
     $dir = scandir(TYPEF_SOURCE_DIR . '/registry');
     $registry = simplexml_load_string('<registry/>');
     foreach ($dir as $file) {
         if (is_file(TYPEF_SOURCE_DIR . "/registry/{$file}")) {
             if (substr($file, -8) == '.reg.xml') {
                 $package = substr($file, 0, -8);
                 $xml = simplexml_load_file(TYPEF_SOURCE_DIR . "/registry/{$file}");
                 foreach ($xml->application as $app) {
                     $app['package'] = $package;
                     if ((string) $app['handler']) {
                         $this->_handlers[(string) $app['base']] = (string) $app['handler'];
                     }
                 }
                 simplexml_merge($registry, $xml);
             }
         }
     }
     $this->_parseRegistry($registry);
     $this->_loadUserPages();
     $configs = new BaseModel_Config();
     foreach ($configs->select() as $c) {
         $this->_configSettings[$c['configname']] = $c['configvalue'];
     }
 }