ob_end_flush(); flush(); $srcdir = GAME_ROOT . './include/modules/' . $modp[$i]; $tpldir = GAME_ROOT . './gamedata/run/' . $modp[$i]; create_dir($tpldir); clear_dir($tpldir); copy_dir($srcdir, $tpldir); foreach ($codelist[$i] as $key) { echo ' 正在处理代码' . $key . '.. '; ob_end_flush(); flush(); $src = GAME_ROOT . './include/modules/' . $modp[$i] . $key; $objfile = GAME_ROOT . './gamedata/run/' . $modp[$i] . $key; $objfile = substr($objfile, 0, -4) . '.adv' . substr($objfile, strlen($objfile) - 4); $delfile = GAME_ROOT . './gamedata/run/' . $modp[$i] . $key; preparse($modn[$i], $i, $src); parse($modn[$i], $src, $objfile); unlink($delfile); echo '完成。<br>'; ob_end_flush(); flush(); } echo '完成。<br>'; ob_end_flush(); flush(); } echo '<font color="blue">代码预处理CODE_ADV2完成。</font><br><br>'; } clear_dir(GAME_ROOT . './gamedata/templates', 1); global $___MOD_CODE_ADV3; if ($___MOD_CODE_ADV1 && $___MOD_CODE_ADV2 && $___MOD_CODE_ADV3) {
//$path = 'laughs.xml'; $opts = getopt('', array('path:', 'loop::', 'pre')); if (!$opts) { echo 'Usage: php parse.php --path <xml_file> [--loop <iterations>] [--pre]' . PHP_EOL; exit(1); } $path = $opts['path']; $loop = $opts['loop'] ?: 1; $pre = isset($opts['pre']); for ($i = 0; $i < $loop; ++$i) { $s = file_get_contents($path); libxml_disable_entity_loader(); libxml_use_internal_errors(true); // Comment out this line to see behavior/performance without preparse step if ($pre) { $s = preparse($s); } $x = simplexml_load_string($s); $acc .= (string) $x; } var_dump($acc); // Take and return an XML string, less DOCTYPE nodes // This takes time to pull in the whole document, doubling the total parsing // time. function preparse($s) { $d = DOMDocument::loadXML($s); foreach ($d->childNodes as $c) { if ($c->nodeType === XML_DOCUMENT_TYPE_NODE) { $d->removeChild($c); }