What I am trying to do is to load a webpage into in a UIWebView. The problem is that I need to do some preprocessing on the html before displaying it in the web view.
The UIWebview loadHTMLString is quiet slow when the html is big. I don't need to display the full page therefore i am trying to remove some html nodes before displaying it in the web view to speed up the loading time.
I don't think using regex for that is a wise idea. I checked out NSXMLParser and TFHPPLE but I couldn't find any way to remove nodes from the html tree using an XPath or something.
I know I could do that using Javascript but that won't solve my problem. I also don't have no control on the website so I can't edit in the webpage itself.
Is there something as easy as deleteNodeUsingXPath or something :)
Cheers and thanks a lot for your help in advance.
One possibility solution: do a proxy website which strips out unwanted stuff. The iphone accesses the proxy website URL. The proxy website loads from the original website, strips out unwanted stuff, and replies with the remaining stuff.
There is a tool called Objective-C-HTML-Parser that will do what you are looking for. The documentation is thorough, and the implementation is pretty straight-forward.
Basically, you take your HTML string and make an HTMLParser object that you can then manipulate however you want. It is a very powerful library that basically lets you do whatever you want with HTML with easy-to-use Objective-C APIs.
Good luck!
Related
I couldn't find any api that return the article in a usable HTML form. Most of them return extracts which have very poor HTML formatting which makes them useless for anything.
There is no way to tell what Facebook did exactly, but the easiest way to grab the HTML contents of an article is by using the render action, i.e. by appending action=render to the URL:
https://en.wikipedia.org/wiki/Cooking?action=render
This produces the exact same HTML you can see on Wikipedia, but omits the non-content part (sidebar etc). If you need to reproduce the layout of an article more faithfully, you need to reuse parts of Wikipedia's CSS, and there is no easy way to do that.
Since just a few days there is a REST API for getting the html. It is available at https://rest.wikimedia.org/
Since it is so new, Facebook is probably not using it (yet) but if you want to get it for yourself I suggest you start exploring there.
I'm building a GWT application that looks great. At the end of the page I'd like to include a WordPress blog that I'm developing. In order to do that I want to use a com.google.gwt.user.client.ui.Frame so that an IFrame gets created, and the Wordpress just gets seamlessly embedded.
I've built this and it seems to work, although there's a problem with the size of the IFrame. I'm not sure how it's getting sized, but it's too small so that scrollbars are thrown onto it. This makes the the embedding not so seamless.
What should I be doing so that this second webiste can be seamlessly embedded into my GWT app?
The easiest solution is to make iframe as big as possible, and hope that there will be no unexpected scrollbars.
Also there is another way, if you have access to the innerDocument of iframe (if SOP doesn't stop you from doing this), you can compare its size against the size of iframe, and increase iframe height/width if necessary.
If blog is in another domain, you might try to use cross-document messaging to retrieve information about the size of document(this will not work in IE7,IE6 and you will have to put some additional JS on your blog).
Also you can include information from your blog without using iframes. You can simply pull RSS of your blog, parse it and display it in any way you like it.
The setup: I have a Blogger blog set up on a domain name as blog.mydomain.com. The main site site at mydomain.com is running Umbraco CMS.
The problem: I need to have the navigation from the CMS transported to Blogger somehow, so that making a change on the main website doesn't require the extra step of modifying the navigation inside Blogger.
Generating the navigation data on the CMS side in what ever format it needs to be (XML, unordered list, JSON, etc) is not a problem. The problem is getting the data from Umbraco to Blogger after it is generated.
I'm not yet willing to use Javascript, as this would seriously impair the website for users browsing without Javascript. (Too bad because AJAX would be a very workable solution.)
I've tossed around the idea of using an iFrame. How would this work for a navigation system including sub-menus? Creating and deleting multiple iframes is out of the picture, since I don't want to use Javascript. I could use one large iframe to allow for the sub-menus, but then it would cover content at the top of the content area, rendering it unclickable.
I'm thinking about how you could do this, but while I do - in this day-and-age javascript has become very common. Most users are going to have it, and those with it disabled really shouldn't be on the web. Is this the only reason you don't want to use javascript? Around 2% according to YDN have js disabled, and that's lower from other countries. As time goes on that 2% should get lower, I don't see that as an issue. However if you absolutely can't use javascript, I'll keep thinking. I might have an idea, I'll need to test it though.
It's not possible to use IFrame, cause of same origin policy. Both sites are on different domains, when user click menu item inside IFrame, there is no way to call parent window.
There are few ways how this can be done.
1) Javascript solution. Use json rpc, or another cross-domain calls. Load menu from your CMS and render it. Yes, this requires javsascript, but, seriously, show me the site, which does not use javascript.
2) Direct server communication.
Is it possible to perform http call from blogger ? If so, just perform http call to your CMS from Blogger, get data and render it.
3) Mixed flash/javascript solution. Flash can perform http call regardless of same origin policy. Get data with flash, use ExternalInterface to call Javascript function to render data.
There is no another way to do it. I suggest you to use javascript solution
You could build an HTML skeleton of empty ULs in Blogger (the max that you might need) to hold your navigation contents, and then link to an Umbraco-generated external stylesheet.
This stylesheet could fill those LIs with CSS generated content using the :before and :after pseudo-elements, and hiding unused LIs with CSS display: none.
An example of this is at: http://jsfiddle.net/5bXja/1/
This works in IE8+ so depending on your clients, this may-or-may-not be more widely supported than Javascript. Likely not. ;-)
I'm looking to create a small reference app. It has a UItabBar and 4 views that each load a UITableView which can be drilled down to display, essentially a page of information and pictures, like a book.
If I want to make the page a little more stylised than just using labels and image views, the common consensus seems to be to create HTML pages and load them in a web view.
Being new to this, please could someone give me some direction on where to even begin with this? As I understand it, I essentially need to develop a web page with a text editor, and then what? Actualy upload online and create a public website? It's a little confusing, and as I'm not a developer, a little disheartening to think I'll now have to learn HTML as well as Obj-C to create a simple app.
I'm sure there are some great tools or alternatives out there and if someone could recommend such avenues I'd be incredibly grateful.
Kind regards,
Ryan
If you want to display HTML pages in a UIWebView you can store them in your bundle and display them from there (so no need to put the pages online). It is best though to stick with the UI controls that Apple provides you with. If you need more customization try subclassing some of the standard controls.
If you customize your UI too much it will just confuse the user and degrade their experience.
I've got experience in C/C++ and am trying to now learn Objective-C for iPhone development. I have very little web design experience.
I'm trying to create an app for a friend's site that accesses a search feature from a website and then display the results in a UITableView. For example, (this isn't the site I'll be using, but...) using the stackoverflow search function and then being able to format the results (https://stackoverflow.com/search?q=iphone+web+search) in cells. I'd like to leave out the rest of the content on the page.
I've only been able to find info about reading xml or rss search results. Otherwise, I could use UIWebView, but that displays the entire site. Are there other classes that I should look into for doing this? Any help would be very, very much appreciated!
The iPhone SDK doesn't include Cocoa libraries for parsing HTML. Just NSXMLParser, which isn't a good tool for what you want to do. (It will choke on valid HTML that isn't valid XML.)
This page is probably a good first place to look. The author says, "For scraping/reading a webpage, XPath is the best choice. It is faster and less memory intensive then NSXMLParser, and very concise. My experience with it has been positive."