CaRP: Caching RSS Parser - Manual
     Version 3.5.4 (10/7/2004)

NOTE: This version of CaRP is obsolete. This documentation is being left here for those who have not yet upgraded to the current version.

Download | Installation | Configuration | Upgrading from version 2 | Functions | Examples | Donations

Old documentation: Version 2

Examples:
Styles & Classes | Multiple Feeds on a Page | Unordered List | Background Refreshing | Filtering | Aggregating 1 | Aggregating 2 | Amazon.com Associates | JavaScript

Converting RSS to JavaScript:

If you are already exporting an RSS feed and would like to make it accessible to more webmasters, you can use CaRP to convert it to a JavaScript. This will enable websites that don't have the capability to import RSS newsfeeds or whose webmasters don't know how to do so to easily import your newsfeed with a single line of HTML code.

Be aware that since the remote website will not cache your JavaScript formatted feed (which they would hopefully, though not necessarily, be doing if they import your RSS formatted feed), this method will use more of your server's bandwidth to serve up your newsfeed to each person who visits their site. For this reason, we strongly recommend urging webmasters subscribing to your newsfeed to use a caching RSS parser, like CaRP, whenever possible.

To use CaRP to convert a newsfeed to JavaScript, create a PHP file like the following:

	<?php
	require_once "/www/templates/global/carp.php";
	 
	CarpConf('outputformat',1);
	CarpConf('maxitems',10);
	CarpConf('ilinktarget',1);
	 
	CarpShow('/rss/headlines.rdf','headlines.js');
	?>

It will then be possible to import your newsfeed into any webpage by adding HTML code like the following to that page:

<script src="http://yourwebsite.com/ThePHPFileCreatedAbove.php"></script>

In the preceding example, the person importing your newsfeed has no control over it's appearance. By creating a more complex PHP page on your site, you can allow them to decide how many news items to display, as well as a number of other formatting options. Notice how this code provides default values in case the webmaster doesn't specify anything.

Note that no cache file is specified in the call to CarpShow. This is important, because the formatting may be different each time this page is loaded. Since you are formatting a local RSS feed in this case, this will not affect performance the way it would with a remote newsfeed.

	require_once "/www/templates/global/carp.php";

	if (!($mi+=0)) $mi=15;
	$hbw+=0;
	$hbc=preg_replace("/[^a-zA-Z0-9. ]/",'',$hbc);
	$hc=preg_replace("/[^a-zA-Z0-9. ]/",'',$hc);
	$nw=preg_replace("/[^a-zA-Z0-9. ]/",'',$nw);

	CarpConf('outputformat',1);
	if (($doClass=strlen($hbc))||$hbw) {
	   CarpConf('bilink','<div '.
	      ($doClass?"class=\"$hbc\" ":'').
	      ($hbw?"style=\"width:$hbw;":'').
	      ($doClass?'':(';background:#cccccc;padding:2px;border-width:1px;'.
	         'border-style:solid;border-color:#333333;')).
	      ($hbw?'"':'').
	   '>');
	   CarpConf('ailink','</div>');
	}
	CarpConf('maxitems',$mi);
	if (strlen($hc)) CarpConf('ilinkclass',$hc);
	CarpConf('ilinktarget',$nw);

	CarpShow('/rss/headlines.rdf','');
	?>

The following HTML code will import a newsfeed from the above PHP file showing a maximum of 8 items, no description fields, using a CSS class defined by the subscribing website (myHead) to set the formatting of the links. Webmasters will be able to set these and other options enabled by your PHP code.

<script src="http://yoursite.com/PHPFile.php?mi=8&hc=myHead"></script>

To help webmasters configure the appearance of your newsfeed, you may also wish to provide a file like the following:

	<html><head><title>Format newsfeed</title>
	<script>
	function UpdateScript() {
	   u='';
	   df=document.f;
	   if (df.mi.value!=15) u='?mi='+df.mi.value;
	   if (df.hc.value.length)
	      u=u+(u.length?'&':'?')+'hc='+df.hc.value.replace(' ','+');
	   if (df.hbc.value.length)
	      u=u+(u.length?'&':'?')+'hbc='+df.hbc.value.replace(' ','+');
	   if (df.hbw.value!=0)
	      u=u+(u.length?'&':'?')+'hbw='+df.hbw.value;
	      
	   nw=Number(df.nw[df.nw.selectedIndex].value);
	   if (nw) u=u+(u.length?'&':'?')+'nw='+nw;
	   
	   df.s.value='<'+'script src="http://yourwebsite.com/PHPFile.php'+
	      u+'"></scr'+'ipt>';
	}
	</script>
	</head><body bgcolor="white">

	<b>Javascript</b>:<br>
	<form name="f" action="javascript:a=1;" method="post">
	Add this HTML to your web page:<p>
	<textarea name="s" rows="2" cols="80" wrap="virtual">&lt;script
	   src="http://yourwebsite.com/PHPFile.php"&gt;&lt;/script&gt;</textarea><p>

	To customize the formatting, use the following form:<br>
	Maximum items to display:
	   <input name="mi" size="3" value="15" onKeyUp="UpdateScript();"><br>
	Headline display:<br>
	   &nbsp;&nbsp;&nbsp;CSS class for link:
	      <input name="hc" size="10" onKeyUp="UpdateScript();">
	      (optional - defined in your stylesheet)<br>
	   &nbsp;&nbsp;&nbsp;CSS class for box surrounding headline:
	      <input name="hbc" size="10" onKeyUp="UpdateScript();">
	      (optional - defined in your stylesheet)<br>
	   &nbsp;&nbsp;&nbsp;Width of box surrounding headline:
	      <input name="hbw" size="4" onKeyUp="UpdateScript();">
	      (optional)<br>
	When user clicks headline, follow link in:
	   <select name="nw" onchange="UpdateScript();">
	   <option selected value="0">the current browser window
	      (and frame, if applicable)
	   <option value="1">a new window
	   <option value="2">the top frame of current browser window
	   </select>
	</form><p>

	<b>RSS</b>:<br>
	The address of the RSS newsfeed is http://yourwebsite.com/headlines.rdf

	</body></html>
	
News Headlines on ANY Website

Import RSS newsfeeds into ANY website! Pick your price:
$29.97: Use Jawfish, our RSS to JavaScript or frames conversion service (works with ALL websites)
Free: Download CaRP SE, our free RSS parser (requires PHP)
$47: Get the high-powered, plugin-extendable version, CaRP Evolution


[CaRP] Unknown option (corder). Please check the spelling of the option name and that the version of CaRP you are using supports this option.

[CaRP] XML error: junk after document element at line 2 - Unknown document format.