Parse error: syntax error, unexpected T_OBJECT_OPERATOR RSS

If you are trying to parse an “XML Feed” in PHP4 somewhat like this way :
$titles->item(0)->nodeValue;

then it wont work in PHP4 because its a chaining process and only works in PHP5

5 Responses to “Parse error: syntax error, unexpected T_OBJECT_OPERATOR RSS”

  1. Tommy Says:

    Well is there any alternative?

  2. adnan rafe Says:

    Well I too was trying for the same but cudnt find a solution so I think the possible solution would be to upgrade your PHP version to php5.

  3. Mohammad Salim Says:

    i have error in RSS

    ERROR: Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/sunkickc/public_html/dev/dipak/210608dipak_system/indiasquare/News/general.php on line 20

    give me suggetion what i am doing

    Scrip:load(‘http://news.google.co.in/nwshp?tab=in&ned=in&topic=n&output=rss’);
    //get elements from “”
    $channel=$xmlDoc->getElementsByTagName(‘channel’)->item(0);
    $title->item(0)->nodeValue;
    $channel_title = $channel->getElementsByTagName(‘title’)
    ->item(0)->childNodes->item(0)->nodeValue;
    $channel_link = $channel->getElementsByTagName(‘link’)
    ->item(0)->childNodes->item(0)->nodeValue;
    $channel_desc = $channel->getElementsByTagName(‘description’)
    ->item(0)->childNodes->item(0)->nodeValue;//output elements from “”
    echo “”;
    $x=$xmlDoc->getElementsByTagName(‘item’);
    for ($i=0; $iitem($i)->getElementsByTagName(‘title’)
    ->item(0)->childNodes->item(0)->nodeValue;
    $item_link=$x->item($i)->getElementsByTagName(‘link’)
    ->item(0)->childNodes->item(0)->nodeValue;
    $item_desc=$x->item($i)->getElementsByTagName(‘description’)
    ->item(0)->childNodes->item(0)->nodeValue;
    echo (““.$item_title.”“);
    echo ($item_desc);
    // echo (“” . $item_title . ““);
    echo (“”);
    // echo ($item_desc . “”);
    }
    echo “”;

    ?>

  4. verboze Says:

    Old post, but for the benefit of those who may visit this site in the future… The solution is to break down the chain call into two calls:

    xtemp = $titles->item(0);
    xrealVar = xtemp ->nodeValue;

    But it’s 2009, I would upgrade to php 5 if possible to take advantage of some of the new features :)

  5. Andy Kos Says:

    thanks to verboze for this solution…

    I have one server with php5 and one with php4 – and need my scripts to work on both servers – Im not in a position to upgrade the one running php4 at this time – its too disruptive.. and I needed a temp workaround for now

    this did the job…

Leave a Reply