Custom RSS Script For RegNow |
|
Wednesday, 10 October 2007 |
|
Here is my custom RSS Script to consume RegNow Feeds which can be notoriously difficult to use using conventional RSS coding like SimplePie RSS or MagPie RSS Parsers. For more RSS Scripts, check out this RSS Parsers.
$URL = "http://dc1datafeed.regnow.com/Srv/xs.aspx?req=1&afid=87917&cid=104&kt=1&dk=&ps=10&pi=2&s=1";
getData($URL);
function getData($url)
{
$data = implode('',file($url));
$xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $data, $vals, $index);
xml_parser_free($xml_parser);
//Uncomment the lines below to see the entire structure of your XML document
echo "<pre>INDEX: \n";
print_r ($index);
echo "\n \n \n VALUES:";
print_r ($vals);
echo "</pre>";
$params = array();
$level = array();
$start_level = 1;
foreach ($vals as $xml_elem) {
if ($xml_elem['type'] == 'open') {
if (array_key_exists('attributes',$xml_elem)) {
list($level[$xml_elem['level']],$extra) = array_values($xml_elem['attributes']);
} else {
$level[$xml_elem['level']] = $xml_elem['tag'];
}
}
if ($xml_elem['type'] == 'complete') {
$php_stmt = '$params';
while($start_level < $xml_elem['level']) {
$php_stmt .= '[$level['.$start_level.']]';
$start_level++;
}
$php_stmt .= '[$xml_elem[\'tag\']][] = $xml_elem[\'value\'];';
eval($php_stmt);
$start_level--;
}
}
echo "<pre>";
print_r ($params);
echo "</pre>";
foreach ($vals as $xml_elem)
{
$a = $vals[1]['attributes']['CATEGORYNAME'];
$t = $vals[1]['attributes']['PRODUCTNAME'];
$u = $vals[1]['attributes'][TRIALURL];
echo $a."<br>";
echo $t."<br>";
echo $u."<br>":
}
}
Enjoy!
|
Filed under Software Niche
|