Page 1 of 1

RSS and W3C

Posted: Mon Nov 15, 2004 9:35 am
by Fluffy
Okay, I am stuck and need someone to help me out. I read and read and found a partial solution but still need to finish my hairsplitting.

I am syndicating some newsfeeds on my site but I am ceating my site to be W3C compliant, a noble cause ;)

Still I get an ampersand problem and some other tags. This is what I have untill now and I apreciate if someone can give me the last puzzle piece :D

Code: Select all

require_once('rss_fetch.inc');
error_reporting(E_ERROR);
define('MAGPIE_CACHE_ON', 1);
define('MAGPIE_CACHE_DIR', 'cache');
define('MAGPIE_CONDITIONAL_GET_ON', 1);
define('MAGPIE_CACHE_AGE', 10800);



$url = 'http://www.b92.net/news/rss/vesti-naslovi.php';
$max_items = 5;
$rss = fetch_rss($url);
$items = array_slice($rss->items, 0, $max_items);

    foreach ($items as $item) {
		$title = $item[title];
		$href = $item[link];
$url   = htmlentities($item[link]);
		
  		echo "<a href=$url  target='_blank'>* $title</a><br>\n";
}
echo "<p>", $rss->channel['title'], "</p>";
Basically I need to fix the </a> and other signs. Thnx in advance

Posted: Mon Nov 15, 2004 9:59 am
by phpScott
I know that W3C standards want everything to be in " " so your line

Code: Select all

<?php
echo "<a href=$url  target='_blank'>* $title</a><br>\n";
?>
should be like

Code: Select all

<?php
echo "<a href="$url"  target="_blank">* $title</a><br>\n";
?>
I use xml spy for my validaiton there is a free home edition avialable
http://www.xmlspy.com/download_spy_home.html

Posted: Mon Nov 15, 2004 10:34 am
by Fluffy
Thnx, that narrowed my errrors down for sure. But I am still hitting my head against the wall. Just when ya think you get it. Check this out, this is a custom. page I am playing with syndicating the news:
http://validator.w3.org/check?uri=http% ... %2F123.php

The problem I keep running into are the signs in their URL's, the &,=,yyyy etc.

I will check the software you mentioned but if you could help me out with the above it would help since the guys from W3C put the questions on the site but no answers 8O

Posted: Mon Nov 15, 2004 10:57 am
by vigge89
<br>s must have an trailing / before the last >, like this: <br />
for the ampersands, you need to use & instead of &, since & makes the UA (User Agent) search for an entity.
also, the page doesn't have any starting or ending html-, head- or body-tags, which are required.

Posted: Mon Nov 15, 2004 11:09 am
by Fluffy
Yea I know about the head tags, just put them in...but....

The Ampersands etc are not being generated by me but by their site. How can I parse them correctly if possible at all?

Posted: Mon Nov 15, 2004 11:34 am
by phpScott
my suggestion to you is to do a view->source and then validate that source as oppossed to your dynamic content as there is almost always bound to be trouble.
That is what I do to try and mantian standarts.
Create as much as I can in XHTML then create my dynamic bits and validate the output and make sure that it meets standards.
As for the answer to your question sorry I can't help further as I don't know.

Posted: Mon Nov 15, 2004 11:37 am
by Fluffy
Ok will do, thnx for the help :)