Reply to Stripping HTML from RSS feed

Your name:

Reply:


Posted by Jason on 11/24/52 11:53

First things first, let me say that I couldn't decide whether to post
this to the PHP ng, or to an XML ng. I know from experience that you
guys know what you're talking about, though, and all of the questions
mean "how to do this in PHP," so I hope I picked the right one ;-)

For about a year, I've been importing Yahoo News headlines into my site
via their RSS feed. But I would much rather import Google News
headlines because I can make them specific to my location. The problem
is that their RSS feed includes HTML, and the script I use can't figure
it out.

Here's an example tag from their most recent feed:

<description><br><table border=0 width= valign=top cellpadding=2
cellspacing=7><tr><td valign=top><a
href="http://news.google.com/news/url?sa=T&ct=us/0-0&fd=R&url=http://www.raleighchronicle.com/2006072105.html&cid=1108150860&ei=hUzBRO_JMpe2aInH4PsB">Truck
Driver Wins $100,000 In Lottery; <b>NC</b> Powerball
Winners</a><br><font size=-1><font color=#6f6f6f>Raleigh
Chronicle,&nbsp;NC&nbsp;-</font> <nobr>2 hours
ago</nobr></font><br><font size=-1>REIDSVILLE -- According to the
<b>NC</b> Lottery Commission, when Dennis Mebane collected his prize
this week from a winning $100,000 instant scratch-off ticket, he
<b>...</b> </font><br></table></description>


The XML tag is <description>, but the script I use to parse it
(rss2array, a cookie-cutter script that I downloaded) can't
differentiate between <description> and <table>. Usually, I would call
<description> by using the variable $rss['items'][$i]['description']
(where $i is the index counter), but with this output I would have to
do something like
$rss['items'][$i]['description']['table'><'tr'><'td'><'b><'font'>...

So I guess I really have 2 questions:

1. Is there a way to strip HTML completely out of the tag? Or better
yet, to make rss2array read the HTML as actual HTML instead of XML
tags?

2. If not, is there a better way to read the XML than through the use
of rss2array? I'm a fairly experienced coder, but don't really use XML
often enough to have a good grasp of the logic.

TIA,

Jason

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация