01-21-2009, 06:07 PM
|
#3 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Here's just one idea. The process is simply: find items which don't belong to our requested category and delete them.
PHP Code:
/** * Filtering an RSS feed by category. */
// Load the XML feed $dom = new DOMDocument(); $dom->load('http://www.talkphp.com/external.php?type=RSS2');
// Query for the items we want to throw away $xpath = new DOMXPath($dom); $nodes = $xpath->query('//item[not(category = "General")]');
// Remove those unwanted items foreach ($nodes as $node) { $node->parentNode->removeChild($node); }
// Output the filtered document header('Content-Type: application/xml; charset='.$dom->encoding); echo $dom->saveXML();
|
|
|
|