homepage Welcome to WebmasterWorld Guest from 54.197.19.35
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
Forum Library, Charter, Moderators: bill & werty

RSS, ATOM, and Related Technologies Forum

    
HTML and RSS is there a way?
Implement RSS with HTML or JavaScript
Kyman




msg:1543129
 5:01 pm on Mar 24, 2005 (gmt 0)

I have been brought in to rebuild and optimize my company's website. Part of my plans include using a few selected RSS feeds inside of the new site to help deliver fresh and relevant content. Since I am fairly new to implementing RSS I have been using JavaScript in the test pages to call up the headlines and brief overview but I am not sure if this is the optimum way to do this. Is there a way in straight HTML to accomplish calling them up and is my current method of using JavaScript search engine friendly? If the search engines are able to read the RSS content with the JavaScript this might be a moot point.

If this post is in the wrong catagory I apologize but since it touches base on HTML, JavaScript, and RSS I was not sure where it fit.

<Sorry, no personal URLs.
See Terms of Service [webmasterworld.com]>

[edited by: tedster at 5:17 pm (utc) on Mar. 24, 2005]

 

flyerguy




msg:1543130
 6:17 pm on Mar 25, 2005 (gmt 0)

If you are constrained to using .htm format pages due to existing site design/search engine placement, you could consider using ModRewrite for Apache or an ISAPI filter rewrite plugin for IIS to rewrite your dynamic URL's back as .htm's.

For example, you create a copy of your current .htm page, save it as a .php or .asp file, then insert one of the two dufferent RSS reading scripts i've included on the end of this.

Then install your URL rewrite and make a rule that rewrites all .php / .asp file extensions back to .htm. You then get dynamic functionality with the legacy .htm name convention.

PS. Stay away from Javascript. I have seen Google make a little more effort than usual in delving into my javascript but it generally makes a mess of it.

PHP Rss reader:
<?php
//begin blog reader
function parse_rss($f) {
$xmlfile = fopen($f, 'r');
if (!$xmlfile) die('cannot open the xml file');
$readfile = fread($xmlfile ,40000);
$parsefile = eregi("<item>(.*)</item>", $readfile ,$arrayreg);
$filechunks = explode("<item>", $arrayreg[0]);
$count = count($filechunks);
echo '<font face=verdana><ul>';
for($i=1 ; $i<=$count-1 ;$i++) {
ereg("<title>(.*)</title>",$filechunks[$i], $title);
ereg("<link>(.*)</link>",$filechunks[$i], $links);
ereg("<description>(.*)</description>",$filechunks[$i], $description);
echo str_replace('hxaxh','a',"<li><font style='font-size: 12px;'><hxaxh target=_blank href ='$links[1]'\>".utf8_decode($title[1])."</hxaxh></font>");
echo "<br><font color=gray style='font-size: 10px;'>".utf8_decode($description[1])."</font></li>";
}
}
?>
<html>
<body>
'DISPLAYS FEED
<?php
$xmlfeed = 'http://rssfeedexample.com/rssfeed.asp';
parse_rss($xmlfeed);
?>
</body>
</html>

ASP Rss Reader:
<html>
<body>
<%
set xmlDoc = createObject("Msxml.DOMDocument")
xmlDoc.async = false
xmlDoc.setProperty "ServerHTTPRequest", true
xmlDoc.load("http://www.rssfeedexample.com/rssfeed.asp")
If (xmlDoc.parseError.errorCode <> 0) then
Response.Write "XML error: "& xmlDoc.parseError.reason
Else
set channelNodes = xmlDoc.selectNodes("//channel/*")
for each entry in channelNodes
if entry.tagName = "title"then
strChannelTitle = entry.text
elseif entry.tagName = "description"then
strChannelDescription = entry.text
elseif entry.tagName = "link"then
strChannelLink = entry.text
end if
next
set itemNodes = xmlDoc.selectNodes("//item/*")
For each item in itemNodes
if item.tagName = "title"then
strItemTitle = strItemTitle & item.text & "#%#"
elseif item.tagName = "link"then
strItemLink = strItemLink & item.text & "#%#"
elseif item.tagName = "description"then
strItemDescription = strItemDescription & item.text & "#%#"
elseif item.tagName = "pubDate"then
strItemPubDate = strItemPubDate & item.text & "#%#"
end if
next
arrItemTitle = split(strItemTitle,"#%#")
arrItemLink = split(strItemLink,"#%#")
arrItemDescription = split(strItemDescription,"#%#")
arrItemPubDate = split(strItemPubDate, "#%#")
response.write "<ul>"
for a = 0 to UBound(arrItemTitle) - 1
response.write "<li>"
response.write "<a target='_blank' href='"& arrItemLink(a) & "'>"& arrItemTitle(a) & "</a>"
if strItemDescription <> ""then
response.write "<br />"& arrItemDescription(a)
end if
if strItemPubDate <> ""then
response.write "<br />"& arrItemPubDate(a)
end if
response.write "</li>"
next
response.write "</ul>"

set channelNodes = nothing
set itemNodes = nothing
End If
%>
</body>
</html>

Kyman




msg:1543131
 6:46 pm on Mar 25, 2005 (gmt 0)

Thanks, that is kind of what I figured. I think the Apache solution would work the best for us but I will have to check with out IT Department to see if we can do this on our servers. I am concerned because you stated it would turn all .php or .asp pages into .htm. We also have several .php pages that we need to remain .php dealing with other functions on our site, so I will need to research this a little more but you have given me a great start! Thanks Again.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved