Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formating RSS feeds

Status
Not open for further replies.
When you bring the feed in, just put the info into HTML elements and simply reference those elements in the CSS to give you what font you want.

I would assume you are pulling the feed in then using the DOM putting it into your page. So just apply styles to the elements you are putting your feed into.

[monkey][snake] <.
 
Actually, I'm not putting it into anything. I just have the about script pasted into my page.

Can you give me an example of what you mean? I'm kinda new to this.

Thanks for the help.
 
Ok here is an example, (this was a throw-together test for RSS, so it may not look nice, but it does the job)

Assuming you pull in the RSS feed, you'd do something like this:

Code:
var itemList = objXML.getElementsByTagName("item");
var itemListLength = itemList.length;
var bodyHTML = "";

for (a = 0; a < itemListLength; a++) {
   var storyNodes = itemList[a].childNodes;
   bodyHTML += "<div><div style='text-align:center'><h3><a href=" + storyNodes[1].text + ">" + storyNodes[0].text + "</a></h3></div>";
   bodyHTML += storyNodes[3].text + "<br />";
   bodyHTML += storyNodes[4].text + "<br /></div>";
}

where objXML is the actual feed. You see, I pull in the childNodes of all the <items> and wrap them in whatever HTML tags I want. I have an inline style above (<div style='text-align:center'>), the only thing you would need to do is style your own CSS in the HTML you wrap the RSS feed text through.

In my example, I just created an innerHTML text to get pasted into the body, there are other ways to do this, but innerHTML is plenty fast and simple to use.

If you don't understand what I'm saying, then post some of your code.



[monkey][snake] <.
 
Thanks a lot for the help. Unfortunatly, I'm not following it too much. I do however understand the concept of what you mean.

I'd give you my code, but that's pretty much all I have. The script:

<script language="javascript" src="</script>

just pasted into my HTML. Could you give me an example of how I could use what you did above to alter this feed? Something I could just paste to see it work, then play around with it? For example, I'm not sure how to assign the feed to the objXML object you have there.

Sorry if this is elementary, I'm still learning this stuff.
 
You are going to have trouble with that since you aren't pulling in an RSS feed as such, i.e. it isn't XML.

What you are doing is calling an asp script that is writing some javascript into your page. This javascript is writing out the preformated information.

I'm sure with enough fiddling with javascript you could perhaps isolate the individual elements, but it really would be easier to try and get the actual XML data.

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.
 
Does the RSS provider offer any info on their website as to any CSS classes or ID's used so you can then style them accordingly.


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Install the Web Developer extension for Firefox and view your page with the feed in it.

One of the options in the "View Source" drop-down is "View Generated Source". This lets you view the source code, including anything that's been generated by Javascript.

Armed with that knowledge, you should be able to write some CSS rules that style the output as you want it.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top