RSS and W3C

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Fluffy
Forum Newbie
Posts: 4
Joined: Mon Nov 15, 2004 9:32 am

RSS and W3C

Post 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
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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
Fluffy
Forum Newbie
Posts: 4
Joined: Mon Nov 15, 2004 9:32 am

Post 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
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post 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.
Fluffy
Forum Newbie
Posts: 4
Joined: Mon Nov 15, 2004 9:32 am

Post 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?
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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.
Fluffy
Forum Newbie
Posts: 4
Joined: Mon Nov 15, 2004 9:32 am

Post by Fluffy »

Ok will do, thnx for the help :)
Post Reply