$file = "contact.xml";
function startElement($parser, $name, $attrs) {
print "$name => ";
}
function endElement($parser, $name) {
print "\n";
}
function characterData($parser, $value) {
print "$value
";
}
$simpleparser = xml_parser_create();
xml_set_element_handler($simpleparser, "startElement", "endElement");
xml_set_character_data_handler($simpleparser, "characterData");
if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while($data = fread($fp, filesize($file))) {
if (!xml_parse($simpleparser, $data, feof($fp))) {
die(xml_error_string(xml_get_error_code($simpleparser)));
}
}
xml_parser_free($simpleparser);
?>