I have had an xml parser script below working for the past couple months. Yesterday it stopped working? Now when the page loads it freezes and I'm left a bit confused. I guess it's possible the rsfeed has changed it's formatting and now my script is somehow not intepereting correctly but I can't see it if it is. The XML file that I'm trying to parse is at: http://yahoo.eonline.com/About/Rss/news.celebs.xml
Thanks
<?php
$backend = "http://yahoo.eonline.com/About/Rss/news.celebs.xml";
function startElement($parser, $tagName, $attrs)
{
global $insideitem, $tag;
if ($insideitem) {
$tag = $tagName;
} elseif ($tagName == "ITEM") {
$insideitem = true;
}
}
function characterData($parser, $data)
{
global $insideitem, $tag, $title, $description, $link, $pubDate;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
case "PUBDATE":
$pubDate .= $data;
break;
}
}
}
function endElement($parser, $tagName)
{
global $insideitem, $tag, $title, $description, $link, $pubDate;
if ($tagName == "ITEM") {
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
$text = strtr ($description, $trans_tbl);
echo "<font face=\"Arial\" size=\"2\"><a href='$link' target='_blank'><b>$title</b></a></font> | <font face=\"Arial\" size=\"1\"><i>$pubDate</i></font><br>";
echo "<br>";
echo "<font face=\"Arial\" size=\"2\">$text</font><br><br>";
$title = $description = $link = $pubDate = $insideitem = false;
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($backend, r);
while ($data = fread($fp, 4096)) {
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
fclose($fp);
xml_parser_free($xml_parser);
?>