XML error: not well-formed (invalid token) at line 13

Discussion in 'XML & RSS' started by gerryt, May 2, 2008.

  1. #1
    I have had this feed on my website for years and now I'm getting this message:
    XML error: not well-formed (invalid token) at line 13
    I dont get it??
    Here is the code from my website:
    Can anyone help me?
    Thanks
    /*
    
    Created by Global Syndication's RSS Parser
    
    http://www.globalsyndication.com/rss-parser
    
    */
    
    
    
    set_time_limit(0);
    
    
    
    $file = "http://news.google.com/news?hl=en&ned=us&ie=UTF-8&q=%22bartender%22&output=rss";
    
    
    
    $rss_channel = array();
    
    $currently_writing = "";
    
    $main = "";
    
    $item_counter = 0;
    
    
    
    function startElement($parser, $name, $attrs) {
    
               global $rss_channel, $currently_writing, $main;
    
               switch($name) {
    
                       case "RSS":
    
                       case "RDF:RDF":
    
                       case "ITEMS":
    
                               $currently_writing = "";
    
                               break;
    
                       case "CHANNEL":
    
                               $main = "CHANNEL";
    
                               break;
    
                       case "IMAGE":
    
                               $main = "IMAGE";
    
                               $rss_channel["IMAGE"] = array();
    
                               break;
    
                       case "ITEM":
    
                               $main = "ITEMS";
    
                               break;
    
                       default:
    
                               $currently_writing = $name;
    
                               break;
    
               }
    
    }
    
    
    
    function endElement($parser, $name) {
    
               global $rss_channel, $currently_writing, $item_counter;
    
               $currently_writing = "";
    
               if ($name == "ITEM") {
    
                       $item_counter++;
    
               }
    
    }
    
    
    
    function characterData($parser, $data) {
    
            global $rss_channel, $currently_writing, $main, $item_counter;
    
            if ($currently_writing != "") {
    
                    switch($main) {
    
                            case "CHANNEL":
    
                                    if (isset($rss_channel[$currently_writing])) {
    
                                            $rss_channel[$currently_writing] .= $data;
    
                                    } else {
    
                                            $rss_channel[$currently_writing] = $data;
    
                                    }
    
                                    break;
    
                            case "IMAGE":
    
                                    if (isset($rss_channel[$main][$currently_writing])) {
    
                                            $rss_channel[$main][$currently_writing] .= $data;
    
                                    } else {
    
                                            $rss_channel[$main][$currently_writing] = $data;
    
                                    }
    
                                    break;
    
                            case "ITEMS":
    
                                    if (isset($rss_channel[$main][$item_counter][$currently_writing])) {
    
                                            $rss_channel[$main][$item_counter][$currently_writing] .= $data;
    
                                    } else {
    
                                            $rss_channel[$main][$item_counter][$currently_writing] = $data;
    
                                    }
    
                                    break;
    
                    }
    
            }
    
    }
    
    
    
    $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");
    
    }
    
    
    
    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);
    
    
    
    // output HTML
    
    
    
    
    
    if (isset($rss_channel["ITEMS"])) {
    
            if (count($rss_channel["ITEMS"]) > 0) {
    
                    for($i = 0;$i < count($rss_channel["ITEMS"]);$i++) {
    
                            if (isset($rss_channel["ITEMS"][$i]["LINK"])) {
    
                            print ("\n<div class=\"itemtitle\"><a href=\"" . "go.php?url=" . $rss_channel["ITEMS"][$i]["LINK"] . "\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</a></div>");
    
                            } else {
    
                            print ("\n<div class=\"itemtitle\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</div>");
    
                            }
    
                             print ("<div class=\"itemdescription\">" . $rss_channel["ITEMS"][$i]["DESCRIPTION"] . "</div><br />");                 }
    
            } else {
    
                    print ("<b>There are no articles in this feed.</b>");
    
            }
    
    }
    
    ?>
    
    Code (markup):

     
    gerryt, May 2, 2008 IP
  2. gerryt

    gerryt Active Member

    Messages:
    374
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Well, it has fixed itself.
    There must have been a problem with the feed from google.
    Thanks for all the input ;)
    Gerry
     
    gerryt, May 3, 2008 IP