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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I format an RSS Feed? Use specific headlines? 1

Status
Not open for further replies.

notfarnow

MIS
May 10, 2005
14
US
Hi, Here is my feed:
It is a series of surf reports for the San Diego, CA area.
I need to display them separately. I have a CSS page that is showing in an iframe and all I need to display is the report "2-3 ft.+ - knee to chest high and poor+" and none of the other info for each area. PLEASE HELP! I am really new to this so any help is very much appreciated. THANKS!!!
 
Well it depends on what you want to display it with...

but, you will typically end up using XPath to get the node you are referring to...

Using DOM, you could use the SelectNodes command like this:

Dom.SelectNodes("//item[contains(title,'2-3 ft.+ - knee to chest high and poor+')]")

try this, and see if it can get you started... (test.html)
Code:
<html>
<body>
<script language="vbscript">
  set Dom=CreateObject("Microsoft.XMLDOM")
  Dom.ASync = False
  Dom.setProperty "SelectionLanguage", "XPath"
  'Dom.Load "test.xml"
  Dom.Load "[URL unfurl="true"]http://www.surfline.com/rss/region.cfm?alias=oceansidecam"[/URL]
  For Each e In Dom.SelectNodes("//item[contains(title,'2-3 ft.+ - knee to chest high and poor+')]")
    document.write e.SelectSingleNode("title").text & "<br/>"
    document.write e.SelectSingleNode("description").text & "<br/>"
    document.write e.SelectSingleNode("pubDate").text & "<br/>"
    document.write "<br/>"
  Next
</script>
</body>
</html>

It displays this on my PC:
Code:
TAMARACK: 2-3 ft.+ - knee to chest high and poor+
Not looking to clean, bird with the afternoon report for Tuesday May 10 at 1:30PM. 2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

SWAMIS/CARDIFF: 2-3 ft.+ - knee to chest high and poor+
Not looking to clean, bird with the afternoon report for Tuesday May 10 at 1:30PM. 2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

PACIFIC BEACH: 2-3 ft.+ - knee to chest high and poor+
Not looking to clean, bird with the afternoon report for Tuesday May 10 at 1:30PM. 2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

MISSION BEACH: 2-3 ft.+ - knee to chest high and poor+
Not looking to clean, bird with the afternoon report for Tuesday May 10 at 1:30PM. 2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

IMPERIAL PIER NS: 2-3 ft.+ - knee to chest high and poor+
Not looking to clean, bird with the afternoon report for Tuesday May 10 at 1:30PM. 2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

IMPERIAL PIER SS: 2-3 ft.+ - knee to chest high and poor+
Not looking to clean, bird with the afternoon report for Tuesday May 10 at 1:30PM. 2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

Hope this Helps ;-)

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Here is another way to show the data, same basic method:
Code:
<html>
<body>
<script language="vbscript">
  set Dom=CreateObject("Microsoft.XMLDOM")
  Dom.ASync = False
  Dom.setProperty "SelectionLanguage", "XPath"
  Dom.Load "[URL unfurl="true"]http://www.surfline.com/rss/region.cfm?alias=oceansidecam"[/URL]
  sText = "2-3 ft.+ - knee to chest high and poor+"
  For Each e In Dom.SelectNodes("//item[contains(title,'" & sText & "')]")
    sArea = e.SelectSingleNode("title").text
    sArea = Left(sArea, Len(sArea) - (Len(sText) + 2))
    document.write sArea & "<br/>"
    document.write sText & "<br/>"
    document.write e.SelectSingleNode("pubDate").text & "<br/>"
    document.write "<br/>"
  Next
</script>
</body>
</html>

Result:
Code:
TAMARACK
2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

SWAMIS/CARDIFF
2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

PACIFIC BEACH
2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

MISSION BEACH
2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

IMPERIAL PIER NS
2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

IMPERIAL PIER SS
2-3 ft.+ - knee to chest high and poor+
Tuesday May 10 at 1:30PM

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Wow, thanks so much. Here is my issue. I need to isolate each one separately and strip the title and date from it so it only reads the report and i need to display one report at a time. These update every day. I am really new to this, so if you can help me in the most basic way possible that would be great. I'm not exactly sure how to implement the what you did above, but it looks great. THANKS!!!
 
I will be posting these reports on my website as html files that are coded with CSS and only contain 1 line saying something like "3-4 + surf occasional head high." if this helps.
 
Can you give an example of EXACTLY what you are looking for?

The RSS feed has multiple Areas, and Multiple levels...

If you can show me what you are going for, I can show you how to get there...

I'm not sure what you mean by:
only contain 1 line saying something like "3-4 + surf occasional head high."

Does that mean that you don't want to tell Where?
Such as TAMARACK, SWAMIS/CARDIFF, PACIFIC BEACH, etc...

Better yet, is there a site that you know of that has something similar to what you are looking for?

RSS feeds usually scroll, or are placed in tables...

Also, did I miss understand you above, did you Only want the items with "2-3 ft.+ - knee to chest high and poor+" or only show that part of the report for ALL items...?

Such as:
Code:
OCEANSIDE
2-3 ft.+ - knee to chest high and poor-fair

O-SIDE PIER
2-3 ft.+ - knee to chest high and poor-fair

O-SIDE PIER NS
2-3 ft.+ - knee to chest high and poor-fair

TAMARACK
2-3 ft.+ - knee to chest high and poor+

SWAMIS/CARDIFF
2-3 ft.+ - knee to chest high and poor+

DEL MAR
2-3 ft.+ - knee to chest high with occasional 4 ft. and poor+

BLACK'S
2-3 ft.+ - knee to chest high with occasional 4 ft. and fair-good

SCRIPPS
2-3 ft.+ - knee to chest high and fair -

HORSESHOES
2-3 ft.+ - knee to chest high with occasional 4 ft. and poor

WINDANSEA
2-3 ft.+ - knee to chest high with occasional 4 ft. and poor+

BIRDROCK
2-3 ft.+ - knee to chest high with occasional 4 ft. and poor

PACIFIC BEACH
2-3 ft.+ - knee to chest high and poor+

MISSION BEACH
2-3 ft.+ - knee to chest high and poor+

OCEAN BEACH
2-3 ft.+ - knee to chest high and poor

SUNSET CLIFFS
1-3 ft - ankle to waist high and poor

IMPERIAL PIER NS
2-3 ft.+ - knee to chest high and poor+

IMPERIAL PIER SS
2-3 ft.+ - knee to chest high and poor+

Here is some code to place in an HTML file: (SurfRSS.html)
Code:
<html>
<body>
<marquee width=100% height=100% scrollamount=2 direction=up loop=true>
<script language="vbscript">
  set Dom=CreateObject("Microsoft.XMLDOM")
  Dom.ASync = False
  Dom.setProperty "SelectionLanguage", "XPath"
  Dom.Load "[URL unfurl="true"]http://www.surfline.com/rss/region.cfm?alias=oceansidecam"[/URL]
  For Each e In Dom.SelectNodes("//item")
    sArea = e.SelectSingleNode("title").text
    x = instr(1, sArea, ":")
    document.write "<b>" & Left(sArea, x-1) & "</b><br/>"
    document.write Mid(sArea, x + 2) & "<br/><br/>"
  Next
  document.write sText
</script>
</marquee>
</body>
</html>

Then simply point your iFrame at it... (myPage.html)
Code:
<html>
<body>
  <table height=100%>
    <col width="15%"/>
    <col width="50%"/>
    <col width="15%"/>
    <tr height="10">
      <td colspan=3><center><h1>Title</h1></center></td>
    </tr>
    <tr>
      <td rowspan=2>
        RSSFeed:<br/>
        [b]<iframe [COLOR=blue]src="surfrss.html"[/color] width="200" height="300" marginheight="0" marginheight="0"></iframe>[/b]
      </td>
      <td>Some Text</td>
      <td>Some Ad</td>
    </tr>
    <tr>
      <td>Some Other Text</td>
      <td>Some More Text</td>
    </tr>
    <tr>
      <td colspan="3" align="center">Closing Footer</td>
    </tr>
  </table>
</body>
</html>

Hope This Helps...

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Thanks for getting back to me. I'll be working with the new stuff now. Here is an example of what I'm working on:
basically, I need to strip down the feed to only display
the surf report info (ie: 2-3 ft.+ - knee to chest high with occasional 4 ft. and poor) This is different for each spot (oceanside, tamarack, birdrock, etc.) every day. The examples above are set up with an iframe showing the report. I hope this helps. You are the MAN for helping me out on this. I've been pulling out my hair over it.
 
I got bored ;-)

Here is a zip file containing all the XML & XSL files you need for this project...


the main XSL file (surf.xsl) is set up like:
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
  <xsl:output method="html" indent="yes"/>
  <xsl:template match="/">
	<xsl:variable name="Name" select="//location" />
	<xsl:variable name="Extrn" select="document('[URL unfurl="true"]http://www.surfline.com/rss/region.cfm?alias=oceansidecam')"[/URL] />
	<xsl:variable name="Title" select="$Extrn//item[contains(title,$Name)]/title" />
	<xsl:variable name="Desc" select="substring-after($Title,':')" />
	<html>
	  <head>
		<title>Surfline Surf Report</title>
		<style type="text/css">
		a       { color: #FF9900; text-decoration: none; }
		a:hover { color: #FF9900; text-decoration: none; }
		.Desc   { color: #ffffff; font-size: 28; font-family: Arial; background-color: #4D4D4D; margin-top: 3 px; margin-left: 3 px; margin-right: 3 px; margin-bottom: 3 px; }
		</style>
	  </head>
	  <body bgcolor="#B3B3B3" leftmargin="0" topmargin="0">
		<div align="center">
		<table id="Table_01" width="224" height="601" border="0" cellpadding="0" cellspacing="0">
		  <tr>
			<td colspan="5"><img src="images/layout_01.gif" width="224" height="67" alt=""/></td>
		  </tr>
		  <tr>
			<td colspan="2"><img src="images/layout_02.gif" width="12" height="147" alt=""/></td>
			<td>
				<IMG SRC="{//pic1}" WIDTH="198" HEIGHT="145" BORDER="0" STYLE="border: 1px solid Black;"/>
			</td>
			<td colspan="2"><img src="images/layout_04.gif" width="12" height="147" alt="" /></td>
		  </tr>
		  <tr>
			<td colspan="5"><img src="{//pic2}" width="224" height="32" alt="" /></td>
		  </tr>
		  <tr>
			<td><img src="images/layout_06.gif" width="9" height="323" alt="" /></td>
			<td colspan="3" class="Desc">
			  <p align="center">
				<b><a href="[URL unfurl="true"]http://www.notfarnow.com"><br[/URL] />SURF:</a></b>
			  </p>
			  <p align="center">
				<xsl:value-of select="$Desc"/>
			  </p>
			</td>
			<td><img src="images/layout_08.gif" width="9" height="323" alt="" /></td>
		  </tr>
		  <tr>
			<td colspan="5"><img src="images/layout_09.gif" width="224" height="31" alt="" /></td>
		  </tr>
		  <tr>
			<td><img src="images/spacer.gif" width="9" height="1" alt="" /></td>
			<td><img src="images/spacer.gif" width="3" height="1" alt="" /></td>
			<td><img src="images/spacer.gif" width="200" height="1" alt="" /></td>
			<td><img src="images/spacer.gif" width="3" height="1" alt="" /></td>
			<td><img src="images/spacer.gif" width="9" height="1" alt="" /></td>
		  </tr>
		</table>
         </div>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

then the XML files look like...
(oceanside.xml):
Code:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="surf.xsl"?>
<surf>
	<location>OCEANSIDE</location>
	<pic1>[URL unfurl="true"]http://cams04.surfline.com/jpeg/cap05/latest0.jpg</pic1>[/URL]
	<pic2>images/oceanside.gif</pic2>
</surf>

(birdrock.xml):
Code:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="surf.xsl"?>
<surf>
	<location>BIRDROCK</location>
	<pic1>[URL unfurl="true"]http://cams01.surfline.com/jpeg/cap72/latest0.jpg</pic1>[/URL]
	<pic2>images/birdrock.gif</pic2>
</surf>

All you have to do is open the XML files like a regular HTML file, and it will be displayed correctly...

enjoy ;-)

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
BTW...

these XML files (and XSL file) should be able to replace your html files...

Such as:
oceanside.xml
replaces:
oceanside.htm
oceansider.htm


I removed the iFrame, and changed the body in the css area to a class, then used that class on the <TD> which originally contained the iFrame

for more details, glance over the XSL file, feel free to ask any questions...

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Yeah... I had that problem last night... it is the encoding...

Do you know what kind of server you are using?

(Unix, Linux, etc...?)

I bet it is encoding them in unicode (or something) and causing it to F@!# Up...

Last night I downloaded the HTML files from your site the cut out the part that was not needed (after I copied the base code to the XSL)

It had me going crazy for a minute... Then I created a new file, copied the contents of the original, and pasted it in the new file and it worked fine... ?!?

So... It's gotta be the encoding ;-)

Try one of these:

(May need to start a new thread about this problem...)



Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
It is an Apache/1.3.29 (Unix) Server
but I'm going to test it on another Apache
running Linux and hopefully it will work.
.
.
Just tested it on Linux here:

Still no dice. I'll look into the encoding. Here is another link that I was using
to pull info from.
One is formatted one isn't. We are going to need to separate this info for use as well
ex: Let me know what you think.

You've been a huge help please let me know if you need any web / advertising / design help now or in the future.
 
Did you ever figure out what was causing the error for sure?

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
No, we tested it on multiple servers and different browsers and everything looked great but the report (ie: 2-3+ occasional 4ft. and fair) didn't display. On WinXP using IE, nothing showed up with a warning saying that 'access to the xsl document wasn't allowed'. Still looking into the encoding. Any thoughts? Did you get it to display on your end?
THANKS!
 
Not with the file from the server...

It worked fine when I downloaded all the pictues to a "Images" sub folder and created fresh text files and pasted the XML into them...

It's something about the server that seems to be changing the format of the files...

I'm not an expert at Servers, and I've only been working with XML for about 6 months or so...
So I'm running short on ideas...

If you do find the solution, please post it back here, and if I stumble accross anything then I will do the same...

Good Luck,
-Josh

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top