TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-21-2009, 03:31 PM   #1 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Big Grin Parse XML categories and create RSS feed out of it...

Hello all,

So I am thinking of having an XML file that contains a few different categories. Is there a way to use php to create the RSS feed for each different category?

For example:
Code:
<items>
<item>
<title></title>
<description></description>
<link></link>
<pubDate></pubDate>
<category>Fire</category>
</item>

<item>
<title></title>
<description></description>
<link></link>
<pubDate></pubDate>
<category>Recreation</category>
</item>
</items>
One RSS feed for Fire, One for Recreation, parsed from the same XML file.

Then link to it like: rss.xml for the feed readers.

Thanks!
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Old 01-21-2009, 04:38 PM   #2 (permalink)
The Frequenter
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

file_put_contents?
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 01-21-2009, 05:07 PM   #3 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,381
Thanks: 5
Salathe is on a distinguished road
Default

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(); 
Salathe is offline  
Reply With Quote
Old 01-21-2009, 05:29 PM   #4 (permalink)
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
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(); 
Thanks for the idea. I see what you are doing there... I only have php4 though... I will try and do something with domxml if I can figure it out there.
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Categories and sub categories Matt Absolute Beginners 11 12-08-2007 09:39 PM


All times are GMT. The time now is 12:58 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design