Reputation: 212
Hi can Anyone tell me how to process this rss feed in php
http://www.ft.com/rss/companies/travel-leisure
when i am executing the below lines
$rss = new DOMDocument(); $rss->load('http://www.ft.com/rss/companies/travel-leisure');
it is giving an error
A PHP Error was encountered
Severity: Warning
Message: DOMDocument::load(): Opening and ending tag mismatch: link line 8 and head in http://www.ft.com/rss/companies/travel-leisure, line: 11
Thanks
Upvotes: 2
Views: 220
Reputation: 943100
If you request http://www.ft.com/rss/companies/travel-leisure
without a User-Agent
HTTP request header, you can get an error message back (under a 200 OK
status).
This is a bug in FT's website.
As a work around, I suggest using cURL to fetch the data, and then feed a string into DOMDocument
.
Upvotes: 2
Reputation: 2560
Why not use a dedicated library like SimplePie to process your RSS feed ?
$feed = new SimplePie('http://www.ft.com/rss/companies/travel-leisure');
$feed->init();
$feed->handle_content_type();
foreach ($feed->get_items() as $item) {
$permalink = $item->get_permalink();
$title = $item->get_title();
// Do what you want...
}
I have not tested this code, it's just to show you an example of use. Here the documentation and an example for more explanations.
Upvotes: 0