Forum Moderators: coopster

Message Too Old, No Replies

RSS is annoying!

Trying to parse!

         

ahmedtheking

4:52 pm on Mar 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, I made a script to write an XML RSS feed from a database via php, now I have to parse that file to give me a little news section!

Here is the code for my PHP:

<?php
// read rss feed and echo html list of news links

function Parse () {
$filename = "/home/williamc/public_html/xml/rss_feed.xml"; // finds the file
$openfile = file ($filename, "r"); // open file
$openfile = implode ("/n",$openfile);

$parsed = explode ("<item>", $openfile);

foreach ($parsed as $parts) {
$title = explode ("<title>", $value);
$title = preg_replace ("</title>","</h3>",$title);
}
}

Parse();

?>

As you can see, it's not complete!

How can I rewrite each RSS item? I thought that if I explode at the '<item>' tag and then add a loop that it would work, but all i get is:

Array
(
[0] =>
)
Array
(
[0] =>
)
Array
(
[0] =>
)
Array
(
[0] =>
)

Any help would be very appreciated! :D

jatar_k

10:32 pm on Mar 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what about using the XML Parser Functions [php.net]?