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!

Parse RSS Feed Information

Status
Not open for further replies.

webdev17

Programmer
Feb 6, 2006
33
US
I am trying to use an RSS feed to pull articles from an external website. All I want to create is a list of links with a short description. This is working for me, but I'd like to modify the way it displays on the screen. The first problem is that the descriptions are too long. Is there an easy way to limit the number of characters in a description, but not cut it off in mid-sentence? Also, I'm storing both the title/link and description within seperate <td> tags. This is the only way I've been able to get the description to appear. I'd actually like the description to appear below the link as shown:

Link/Title
Short description

This is the code I have for that portion:

Code:
<tr>
     <td valign="top"><a datafld="link" target="_blank"><span datafld="title" /></a></td>
     <td><span datafld="description" /></td>
</tr>

Any advice you could provide would be great. Thanks!
 
designer17 said:
Is there an easy way to limit the number of characters in a description, but not cut it off in mid-sentence?
Definitely not in HTML or CSS. You will need to use whatever technique you use to parse the RSS to modify that.

As for your output layout, I would do it something like this:
Code:
<h1>Title/link</h1>
<p>Short Description</p>
Alternatively, if this is more of a list of things, you might opt for something like:
Code:
<dl>
  <dt>Title/Link</dt>
  <dd>Short Description</dd>
  ...
</dl>
 
Well the problem is that when I put it in any other format other than:

Code:
<tr>
     <td valign="top"><a datafld="link" target="_blank"><span datafld="title" /></a></td>
     <td><span datafld="description" /></td>
</tr>

the description does not show up. I've tried using breaks, putting it in different types of tags, but nothing other than the code above displays the description.

I was also looking for some advice on how to parse the RSS. I am unclear of how to make that work. This is my first experience with RSS. Thanks!
 
Well, we cannot solve your problems based on that. I suggest you do the following:

1. Look at the script that parses your RSS and see what language it is written in. Then visit the forum dedicated to that language and ask all the parsing questions (including the cutting description short.
2. If you are still not getting the result displayed, check your client-side code (do view source on the rendered page) and paste it here, trying to find out why it is not working.
 
Well, I learned something today.

Aside from being non-semantic and not particularly elegant, there's nothing wrong with the HTML you posted. However, what you're doing is not pure HTML, but an XML data islands in an HTML document. At least, I assume that's what you're doing, as it's the only interpretation of your code that makes even a little sense to me. Not to be rude, but you really should have mentioned that in your initial post.

As for this method, I would recommend against it. This functionality seems to be a semi-official feature of Internet Explorer and will almost certainly fail miserably in every other browser on Earth. Some XSL-T, JavaScript DOM stuff, or server-side processing would be much more compatible.

With regard to the problem itself, I'd say it's most likely in the link between your data fields and the XML document. Don't ask me where, though, as I don't know anything about this feature of IE. Heck, I can't even find any official documentation on it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top