note 92903 added to book.simplexml

From: Date: Thu, 13 Aug 2009 18:43:33 +0000
Subject: note 92903 added to book.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-159456@lists.php.net to get a copy of this message
Correcting/adding to charlie at blankcanvasstudios dot com's code: function is_rss($feedxml) { $feed = @simplexml_load_string($feedxml); return($feed->channel->item && stripos($feedxml,'<rss')!==false)?true:false; } function is_atom($feedxml) { $feed = @simplexml_load_string($feedxml); $ns = implode('',$feed->getNamespaces()); return($feed->entry && strpos($ns,'Atom')!==false)?true:false; } The original function simply checked that the input follows the same general XML structure as RSS/Atom, but not much beyond that. To do a *slightly* deeper check I propose a namespace check on the feed (for Atom) and a verification that there's an <rss> tag (for RSS). ---- Server IP: 64.71.164.2 Probable Submitter: 71.136.198.195 ---- Manual Page -- http://www.php.net/manual/en/book.simplexml.php Edit -- https://master.php.net/note/edit/92903 Del: integrated -- https://master.php.net/note/delete/92903/integrated Del: useless -- https://master.php.net/note/delete/92903/useless Del: bad code -- https://master.php.net/note/delete/92903/bad+code Del: spam -- https://master.php.net/note/delete/92903/spam Del: non-english -- https://master.php.net/note/delete/92903/non-english Del: in docs -- https://master.php.net/note/delete/92903/in+docs Del: other reasons-- https://master.php.net/note/delete/92903 Reject -- https://master.php.net/note/reject/92903 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159456) next »