public function parseFile($filename, $config = null, $encoding = 'utf8', $use_include_path = false) { parent::parseFile($filename, $this->config + (array) $config, $encoding, $use_include_path); }
$config = array('indent' => true, 'input-xml' => true, 'output-xml' => true, 'wrap' => false); $files = scandir('.'); $qnumber = 0; foreach ($files as $file) { if (strpos($file, "question") === false) { continue; } if (strpos($file, ".xml") === false) { continue; } $qnumber++; // if ( $qnumber <= 5 ) continue; // echo("+++++++++++++\n$$file $qnumber\n"); // Tidy $tidy = new tidy(); $tidy->parseFile($file, $config); $tidy->cleanRepair(); // Output // echo tidy_get_output($tidy); $DOM = simplexml_load_string(tidy_get_output($tidy)); // echo $DOM->asXML(); $itemBody = $DOM->itemBody; $div = $itemBody->div; $question_text = $div->asXML(); // Get rid of some crap.. $question_text = str_replace(array('<p/>', '<div/>'), array('', ''), $question_text); // Uh lets say good by to <spans...> $question_text = preg_replace('/<span.*?>/', '', $question_text); $question_text = preg_replace('/<\\/span>/', '', $question_text); $question_text = trimBlankLines($question_text); // Pull out the mneme way of indicating short answer.