paragony2k
01-11-2006, 04:49 PM
Hello,
After 2 weeks of trying to figuar this out on my own to no avail, I present you with my problem that I know has a very simple solution. I have PHP4 on my server. I was pulling a search feed with this parse and it has worked for a long time, and it still works with the given search feed. We have changed our search feed and now I am presented with a problem. This is what the XML structure looks like:
<listing>
<title>
<![CDATA[ Website Hosting Links Best On The Web]]>
</title>
<url>
<![CDATA[ http://www.blahblahblah.com]]>
</url>
<redirect>
<![CDATA[ http://search.blahblah.com]]>
</redirect>
<description>
<![CDATA[ The best blahs and blah blah blah blah blah around. Why not blah
blah blah blah for yourself? Blah!]]>
</description>
<bid>
<![CDATA[ 0.00]]>
</bid>
</listing>
Now the only difference in the xml feed is the added <![CDATA]> and I cannot figuar out how to parse it with the parser I have been using for a while now. WHich is as follows:
<?
function get_blahblahsearch($keyword,$user_ip){
$DATA = fopen("http://www.blahblah.com/feed_string_here");
$feed = '';
while (!feof($DATA)) {
$feed .= fread($DATA, 8192);
}
fclose($DATA);
$feed = utf8_decode($feed);
$n_results = 0;
while (eregi("(<TITLE>)([^<]+)",$feed,$out)){
$results[$n_results]["title"] = $out[2];
$results[$n_results]["title"] = html_entity_decode($results[$n_results]["title"]);
eregi("(<DESCRIPTION>)([^<]+)",$feed,$out);
$results[$n_results]["description"] = $out[2];
$results[$n_results]["description"] = html_entity_decode($results[$n_results]["description"]);
eregi("(<URL>)([^<]+)",$feed,$out);
$results[$n_results]["siteHost"] = $out[2];
eregi("(<REDIRECT>)([^<]+)",$feed,$out);
$results[$n_results]["link"] = urldecode($out[2]);
$feed = substr($feed,strpos($feed,$out[0])+strlen($out[0]));
$n_results += 1;
};
return $results;
};
?>
<?
$ip = getenv("REMOTE_ADDR");
$keyword = $_REQUEST["q"];
$results = get_blahblahsearch($keyword,$ip);
if ($results){
// sample output
foreach ($results as $result){
echo "<tr><td colspan=2><p align=justify>";
echo "<a href=\"" . $result['link'] . "\" target=top><font color=#336699 size=3>" . strip_tags($result['title']) . "</a></font>";
echo " - <font color=#3BA101 size=1><b>" . $result['siteHost'] . "</b></font><br>";
echo "<font color=midnightblue size=1>" . strip_tags($result['description']) . "</font><br><br>";
echo "</p>";
echo "</td><tr>";
}
}
?>
Any help at this point will be greatly appreciated.
Thank you for your time,
Daniel :gthumb:
After 2 weeks of trying to figuar this out on my own to no avail, I present you with my problem that I know has a very simple solution. I have PHP4 on my server. I was pulling a search feed with this parse and it has worked for a long time, and it still works with the given search feed. We have changed our search feed and now I am presented with a problem. This is what the XML structure looks like:
<listing>
<title>
<![CDATA[ Website Hosting Links Best On The Web]]>
</title>
<url>
<![CDATA[ http://www.blahblahblah.com]]>
</url>
<redirect>
<![CDATA[ http://search.blahblah.com]]>
</redirect>
<description>
<![CDATA[ The best blahs and blah blah blah blah blah around. Why not blah
blah blah blah for yourself? Blah!]]>
</description>
<bid>
<![CDATA[ 0.00]]>
</bid>
</listing>
Now the only difference in the xml feed is the added <![CDATA]> and I cannot figuar out how to parse it with the parser I have been using for a while now. WHich is as follows:
<?
function get_blahblahsearch($keyword,$user_ip){
$DATA = fopen("http://www.blahblah.com/feed_string_here");
$feed = '';
while (!feof($DATA)) {
$feed .= fread($DATA, 8192);
}
fclose($DATA);
$feed = utf8_decode($feed);
$n_results = 0;
while (eregi("(<TITLE>)([^<]+)",$feed,$out)){
$results[$n_results]["title"] = $out[2];
$results[$n_results]["title"] = html_entity_decode($results[$n_results]["title"]);
eregi("(<DESCRIPTION>)([^<]+)",$feed,$out);
$results[$n_results]["description"] = $out[2];
$results[$n_results]["description"] = html_entity_decode($results[$n_results]["description"]);
eregi("(<URL>)([^<]+)",$feed,$out);
$results[$n_results]["siteHost"] = $out[2];
eregi("(<REDIRECT>)([^<]+)",$feed,$out);
$results[$n_results]["link"] = urldecode($out[2]);
$feed = substr($feed,strpos($feed,$out[0])+strlen($out[0]));
$n_results += 1;
};
return $results;
};
?>
<?
$ip = getenv("REMOTE_ADDR");
$keyword = $_REQUEST["q"];
$results = get_blahblahsearch($keyword,$ip);
if ($results){
// sample output
foreach ($results as $result){
echo "<tr><td colspan=2><p align=justify>";
echo "<a href=\"" . $result['link'] . "\" target=top><font color=#336699 size=3>" . strip_tags($result['title']) . "</a></font>";
echo " - <font color=#3BA101 size=1><b>" . $result['siteHost'] . "</b></font><br>";
echo "<font color=midnightblue size=1>" . strip_tags($result['description']) . "</font><br><br>";
echo "</p>";
echo "</td><tr>";
}
}
?>
Any help at this point will be greatly appreciated.
Thank you for your time,
Daniel :gthumb:
