-function endElement($parser, $name) {
- global $depth, $stack;
- array_pop($stack);
- $depth[$parser]--;
-}
-
-function characterData($parser, $data) {
- static $last = '';
- global $depth, $stack;
- $current = join('/', $stack);
- $data = trim($data);
- if ($data) {
- echo str_repeat(TAB, @$depth[$parser]);
- if ($current !== $last) {
- $last = $current;
- echo "En $current: ";
- } else {
- echo " ";
- }
- echo "'$data'\n";
- }
-}
-
-$xml_parser = xml_parser_create();
-xml_set_element_handler($xml_parser, "startElement", "endElement");
-xml_set_character_data_handler($xml_parser, "characterData");
-if (!($fp = @fopen($file, "r"))) {
- die("could not open XML input\n");
-}
-
-while ($data = fread($fp, 4096)) {
- if (!xml_parse($xml_parser, $data, feof($fp))) {
- die(sprintf("XML error: %s at line %d\n",
- xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)));
- }
-}
-xml_parser_free($xml_parser);
+$parser =& new BIFE_Parser($template);
+$parser->parseFile($file);
+echo $parser->getOutput();
+$parser->__destruct();