note 92904 added to book.simplexml

From: Date: Thu, 13 Aug 2009 18:43:41 +0000
Subject: note 92904 added to book.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-159457@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/92904 Del: integrated -- https://master.php.net/note/delete/92904/integrated Del: useless -- https://master.php.net/note/delete/92904/useless Del: bad code -- https://master.php.net/note/delete/92904/bad+code Del: spam -- https://master.php.net/note/delete/92904/spam Del: non-english -- https://master.php.net/note/delete/92904/non-english Del: in docs -- https://master.php.net/note/delete/92904/in+docs Del: other reasons-- https://master.php.net/note/delete/92904 Reject -- https://master.php.net/note/reject/92904 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159457) next »