note 84263 deleted from class.domnodelist by joey

From: Date: Tue, 16 Oct 2012 00:54:45 +0000
Subject: note 84263 deleted from class.domnodelist by joey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191312@lists.php.net to get a copy of this message
Note Submitter: saad0105050 at gmail dot com ---- Problem with accessing return value of DOMNodeList::item() method. When using the following code segment: --------------------- $messageNodes = $doc->getElementsByTagName( "message" ); if( $messageNodes != NULL ) { $messageStr = $messageNodes->item( 0 )->firstChild->nodeValue; } --------------------- PHP gives an error: "syntax error, unexpected T_OBJECT_OPERATOR" But if I modify it like the following: --------------------- $messageNodes = $doc->getElementsByTagName( "message" ); if( $messageNodes != NULL ) { $messageNode = $messageNodes->item( 0 ); $messageStr = messageNode->firstChild->nodeValue; } --------------------- There is no error. I guess, the return element of DOMNodeList::item() function can not be readily accessed via "->" operator.

« previous php.notes (#191312) next »