I have an rss reader app which works perfectly on some feeds, but on others it just displays text and no images.
Is it the feed which should be adjusted to publish images or Im sure it is something with the way I read the stream.
Why does it work for some streams(shows entire posts, images, videos etc. from e.g. blogspot rss feeds) but not for other rss feeds?
I have read that the stream itself can be set to publish different content amounts.
How can I parse the feed so that all feeds will work correctly?
It's very likely that it's due to the feed themselves... and not to the reader app.
Feed publisher can decide whether they want to include all or parts only of their content in their feeds (RSS or Atom).
Then, even if they publish all the content, they may decide to publish it as raw text (just the text content) or full XHTML, which would allow the inclusion of images.
Unfortunately, there is little that you can do, except maybe ask the developer of your app to allow to show the original site/page and not just the feed entries.
Ok, so what are the differences between the feeds that work and the feeds that don't? What assumptions do you make about the RSS content, and in what situations are those assumptions not satisfied? When you run the code in the debugger, what do you see when you encounter a feed where images don't work? Also, what code? ;)
Related
I have been looking around for a while and not found anything useful, also not sure if I have worded the question in the clearest fashion so apologies
I have a section of an app I am building called 'Company News'. The company in question has a news page on their website which displays a title, an excerpt of text and a read more option.
At the minute in the iPhone application I just have a UIWebView which links to that URL, displays an error if no connection is available. However, if my user clicks a story to read the news obviously it opens up a new page, I want to avoid having to build in 'back' and 'forward' buttons and stay away from it looking like a browser within the app.
With that said, I am looking for a way to just extract that data from the website and just display it in my app as raw text. I am not particularly bothered about rich text formatting or anything fancy. I would just like the title and body of text.
Is this possible?
In essence, then, you are looking for an HTML parser.
Assuming the HTML you wish to parse has a predictable format, the approach I would take is to load the HTML via whatever URL loading system you want - e.g. NSURLConnection, ASIHTTPRequest, etc.
Then you will need to parse the raw HTML. I use XPath. It requires that you learn the syntax, but it should work.
For more details about how you might use XPath for parsing HTML, see the second response to this question. You will need to link to libxml2 in your project then use XPath to extract the nodes of interest.
Scraping web pages in this way is fragile, though, because it depends on the structure of a page you don't control and which could be changed unpredictably.
I'm wondering if it's possible to edit out certain parts of the html code. It's really longa and as I parse it (with element parser), the deeper the parser goes into the code the slower it runs. Any ideas? I'm using a 3G as well.
edit:
For example on this site I'd want the posts and the usernames. Let's say there are like 50 replies on this thread and assume it will take a long time for the 3G phone to parse thousands of lines.
I'd want to remove the right links, the ads, the links at the top and bottom of the page too. Then I'd get the revised html and push it into the parser.
If you downloading a webpage using UIWebView, then you can use normal javascript to (by using the method stringByEvaluatingJavascriptFromString) to hide or remove any elements you want to remove from the view of the user.
I have seen some tutorials on the subject, but they all go half into it and then leave a person wondering.
How can I stream an rss feed into an iphone app.
I know the xml should be read in, parsed etc.
But then I am not sure how to display the information I need like, images, embedded videos etc.
If someone could just point me in the right direction I would be extremely grateful.
Thanks in advance
First, you need some type of XML parser. You can use the built in NSXMLParser or a slew of other parsers that you will need to download. Each have their pros/cons depending on what type of reading/writing you will be doing with your RSS feed.
To display the data, I would recommend a tableView. You can create custom UITablvewCells for each cell to hold the data however you want to display it. There are several tutorials available for that if you want to Google for it.
As for data, read all the RSS data into an array you create and have the tableView access that array.
Again, there are many online tutorials for this already but it seems like you need help with displaying the data. A quick Google lookup for how to create custom UITableViewCells should provide you lots of helpful links. Good luck.
The iPhone makes it really simple to snarf down an image from the web; you can turn a URL into a UIImage in one line of code. So I'd like to enable my app (an educational puzzle game... my first!) to download some random images to make it more interesting and dynamic.
I thought about using Kodak's image of the day RSS feed, but I'm having quite a time figuring out how to parse it. Rather than being a simple list of image URLs, it seems to reference a bunch of "jhtml" URLs, which run Javascript to display the images in your RSS reader. Is this intentionally obfuscated, or am I missing some basic step to parse this?
I also tried the Astronomy Picture of the Day, via this RSS feed, but it's just the original page's HTML stuffed into CDATA... ugh.
So I guess this is really two questions:
Is there a simple way to parse these feeds to actually get at the JPG URLs on the iPhone?
Is there a better source for "picture of the day" type images?
PS: I'm using NSXMLParser, which I learned to use here.
I would recommend going with something that has an API, perhaps the Flickr "Interestingness" feed:
http://www.flickr.com/services/api/flickr.interestingness.getList.html
There is an objective-C library written to help with accessing Flickr but not sure if this API call is included:
http://github.com/lukhnos/objectiveflickr/tree/master
I am using ROME library for parsing feeds. I want to know how can I identify a link as an XML link or a normal link. Is there a support for this in ROME.
It sounds like you are saying that you will be getting a bunch of links from somewhere (RSS feed content or something). Then you want to go through them and determine if they are RSS/Atom feeds or if they are regular HTML pages.
You could probably attempt to fetch it with Rome and then see if it throws an exception. A better option might be to pull in the document at the end of each link and see what the header says it is.
Keep in mind that retrieving each link is may run into a problem if someone links to a very large file.
You might look at using the HEAD command to find out what type of file you are going to get at the end of a link before downloading the entire thing.