"; echo "$d "; } else echo "??? "; } else if ($name == "link") { $current_link_ref = (isset($attribs["ref"])) ? $attribs["ref"] : ""; echo ""; if (count($attribs) && isset($attribs["img"])) { $pic = $attribs["img"]; echo ""; $current_tag_body_is_empty = false; } } else if ($name == "list") { echo "
    "; } else if ($name == "li") { echo "
  • "; } } function endElement($parser, $name) { global $max_items; global $current_tag; global $current_tag_body_is_empty; global $current_link_ref; if ($max_items == 0) return; array_pop($current_tag); if ($name == "entry") { echo "
\n"; if ($max_items > 0) $max_items--; } else if ($name == "link") { if ($current_tag_body_is_empty) echo $current_link_ref; echo ""; $current_link_ref = ""; // reset } else if ($name == "list") echo ""; else if ($name == "li") echo ""; } function characterData($parser, $data) { global $max_items; global $current_tag; global $current_tag_body_is_empty; $current_tag_body_is_empty = false; if ($max_items == 0) return; echo $data; } if (isset($_GET['max_items'])) { $max_items = $_GET['max_items']; } $xml_parser = xml_parser_create(); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); 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 news XML file!"); } while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); ?>