Hi im trying to add more than one feed per page but I keep getting error can anyone help.
Cheers
Many Thanks. but one more problem.
I need to add a header to each record item
ie
sport
the xml feed
news
then xml feed
shobiz
then xml feed
below is a sample of my code
<?php
require("MagicParser.php");
function myRecordHandler1($item)
{
print "<table width='50%' border='0' align='' cellspacing='0' cellpadding='4' class='leftfloat'>";
print "<tr>";
print "<td width='20' valign='top'><img src='".$item["IMG"]."' /></td>";
print "<td><a href='".$item["LINK"]."' target='_blank'>".$item["TEASER"]."</a></td>";
print "</tr>";
print "</table>";
}
MagicParser_parse("http://www.newsoftheworld.co.uk/notw_sport_feed.xml","myRecordHandler1");
function myRecordHandler2($item)
{
print "<table width='50%' border='0' align='' cellspacing='0' cellpadding='4' class='leftfloat'>";
print "<tr>";
print "<td width='20' valign='top'><img src='".$item["IMG"]."' /></td>";
print "<td><a href='".$item["LINK"]."' target='_blank'>".$item["TEASER"]."</a></td>";
print "</tr>";
print "</table>";
}
MagicParser_parse("http://www.newsoftheworld.co.uk/notw_news_feed.xml","myRecordHandler2");
function myRecordHandler3($item)
{
print "<table width='50%' border='0' align='' cellspacing='0' cellpadding='4' class='leftfloat'>";
print "<tr>";
print "<td width='20' valign='top'><img src='".$item["IMG"]."' /></td>";
print "<td><a href='".$item["LINK"]."' target='_blank'>".$item["TEASER"]."</a></td>";
print "</tr>";
print "</table>";
}
MagicParser_parse("http://www.newsoftheworld.co.uk/notw_showbiz_feed.xml","myRecordHandler3");
?>
No problem - just print out some header tags before each call to MagicParser_parse() - like this:
<?php
require("MagicParser.php");
function myRecordHandler1($item)
{
print "<table width='50%' border='0' align='' cellspacing='0' cellpadding='4' class='leftfloat'>";
print "<tr>";
print "<td width='20' valign='top'><img src='".$item["IMG"]."' /></td>";
print "<td><a href='".$item["LINK"]."' target='_blank'>".$item["TEASER"]."</a></td>";
print "</tr>";
print "</table>";
}
// Sport
print "<h1>Sport</h1>";
MagicParser_parse("http://www.newsoftheworld.co.uk/notw_sport_feed.xml","myRecordHandler1");
function myRecordHandler2($item)
{
print "<table width='50%' border='0' align='' cellspacing='0' cellpadding='4' class='leftfloat'>";
print "<tr>";
print "<td width='20' valign='top'><img src='".$item["IMG"]."' /></td>";
print "<td><a href='".$item["LINK"]."' target='_blank'>".$item["TEASER"]."</a></td>";
print "</tr>";
print "</table>";
}
// News
print "<h1>News</h1>";
MagicParser_parse("http://www.newsoftheworld.co.uk/notw_news_feed.xml","myRecordHandler2");
function myRecordHandler3($item)
{
print "<table width='50%' border='0' align='' cellspacing='0' cellpadding='4' class='leftfloat'>";
print "<tr>";
print "<td width='20' valign='top'><img src='".$item["IMG"]."' /></td>";
print "<td><a href='".$item["LINK"]."' target='_blank'>".$item["TEASER"]."</a></td>";
print "</tr>";
print "</table>";
}
// Showbiz
print "<h1>Showbiz</h1>";
MagicParser_parse("http://www.newsoftheworld.co.uk/notw_showbiz_feed.xml","myRecordHandler3");
?>
Hope this helps!
David.
Hi There,
Firstly, what error message are you getting?
When processing more than one feed in the same script; the main thing you have to consider is that need a different record handler function for each feed, for example:
<?php
require("MagicParser.php");
function myRecordHandler1($record)
{
// process records in feed 1 here
}
MagicParser_parse("feed1.xml","myRecordHandler1");
function myRecordHandler2($record)
{
// process records in feed 2 here
}
MagicParser_parse("feed2.xml","myRecordHandler2");
?>
Also, make sure that you are only including MagicParser.php once, as a second include will also generate an "..is already defined" error.
Hope this helps!
Cheers,
David.