Hello,
I had this problem a while ago. I had to set up the XML feed for a PPC engine from
http://www.browsehosts.com on my site
the browsehosts admin helped me set it up.
Here's the code which is on
http://www.hostlead.com/toplist/ :
<?php
class Record {
var $url;
var $bid;
var $siteurl;
var $title;
var $description;
function Record ($aa) {
foreach ($aa as $k=>$v)
$this->$k = $aa[$k];
}
}
function readDatabase($filename) {
$data = file_get_contents($filename);
//$data = implode("",file($filename));
$parser = xml_parser_create();
xml_parser_set_option($parser,XML_OPTION_CASE_FOLD ING,0);
xml_parser_set_option($parser,XML_OPTION_SKIP_WHIT E,1);
xml_parse_into_struct($parser,$data,$values,$tags) ;
xml_parser_free($parser);
// loop through the structures
foreach ($tags as $key=>$val) {
if ($key == "record") {
$ranges = $val;
for ($i=0; $i < count($ranges); $i+=2) {
$offset = $ranges[$i] + 1;
$len = $ranges[$i + 1] - $offset;
$tdb[] = parseit(array_slice($values, $offset, $len));
}
} else {
continue;
}
}
return $tdb;
}
function parseit($mvalues) {
for ($i=0; $i < count($mvalues); $i++)
$record[$mvalues[$i]["tag"]] = $mvalues[$i]["value"];
return new Record($record);
}
$db = readDatabase("http://www.browsehosts.com/xmlsearch.php?keywords=budget+hosting&pageresult=2 0&startat=0&adult_filter=0&username=hostlead");
//function to print each result:
function printresult ($value,$name) {
print("
<li><strong><font size=\"2\"><a href='$value->url' target=\"_top\">$value->title</a></font></strong><br>$value->description
(Cost to advertiser: <a href=\"http://www.browsehosts.com/signup.php?referal=hostlead\">\$$value->bid</a>)<br></li>
");
}
//Actually print the stuff:
print "<font size=\"1em\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
print "<ol>\n"; //using an ordered list, with font setup above
array_walk($db,printresult);
print "</ol></font>\n";
?>
I know yours will be different but I hope this kind of helps you.
HostLead