Is there any way I can grab only the title, author, date, and text from a WordPress website’s article through its RSS feed? I’m trying to create an iOS app (Xcode) that can display this information.
EDIT:
I am currently using rshankras’ BlogReader code to fetch articles from the website, but it displays the actual link to the page. I’m looking to be able to access the article’s title, author, date, and text, and be able to format it myself, instead of having the actual site show up. What tools can I use to do this, if feasible?
This is the website in question.
You are using a ready-made app so I think, you will have to modify it yourself to serve your purpose. For showing content as you want, you need to manipulate the HTML content instead of viewing it in WebView.
Inside your app, the WebView element is in PostViewController.swift file. So if your put the following code in line number 24 of that file, you will get the URL that is being requested.
This code prints the output in console. Now as you know the url. You can simply fetch the HTML Code and manipulate and show it as your heart want using the following way:
This will print the full HTML Code string encoded using UTF-8.
Now in the postViewController, instead of using WebView element, you can use a label, or textbox or whatever you want to show your content inside. Then create an outlet for that element. And then manipulate the HTML Code String by following way:
Now you have the author name and you can show it in any textbox or label or in any element that support text. You can grab all other info from that page in the same way. I hope it helped.
Since RSS comes in a structured XML format, you can simply fetch your page’s rss feed and parse the elements for the needed data. To see some how to code, you may check out mwaterfalls’ Feedparser
e.g