Using TouchXML with HTML Tidy - iphone

I am trying to set up TouchXML in my iPhone app to parse HTML from a website, but unfortunately the website's HTML isn't valid XML. I'd like to use HTML tidy to tidy it up, and in fact TouchXML has a setting, TOUCHXMLUSETIDY, which when turned on in fact does this. But when I turn on this setting, I get the following errors: Tidy.h: No such file or directory found. I have libtidy.dylib installed in my target, and tried downloading the HTML Tidy source and putting it directly into my app, but nothing is working. Any suggestions for how to tidy up HTML into valid XML on the iPhone?

Tidy.h is found in /usr/include/tidy add that to your User Header Search Paths in xcode as well as add -ltidy to your Other Linker Flags. You should be all set.

Did you download the TouchXML?
Then you should add the files in /TouchXML/Externals/tidy/src to your project. That's the tidy!

Related

How to solve iPhone app hpple HTML Parsing 'libxml/tree.h' file not found?

I am trying to parse HTML URL content using hpple for iPhone app. I want to parse and get data from like this URL http://www.example.com/mobile/403.html. I have used Google and found hpple for HTML parsing. I got the sample HTML parsing hpple code from github. When i start to run the project the below error is occurring
'libxml/tree.h' file not found
I have added this line ${SDKROOT}/usr/include/libxml2 in project->build->header search paths but not it is looking like this iPhoneos3.1.2/usr/include/libxml2/** and also i have included libxml2.dylib and libxml2.2.dylib in my project. Am working in XCode 4.2. Could you please help to solve this error? Thanks in advance.
Make sure you add this line:
${SDKROOT}/usr/include/libxml2
in TARGETS->build->header search paths...
and make sure that you copied your hpple files into your project like this...
Good luck and hope this helps!

iPhone Safari offline-cache manifest not working correctly

I'm working on a mobile site for the iphone. I've added a cache manifest and loaded it with a list of resources needed for offline capability. The manifest file has the correct content type. You can view the manifest file in the header of this page:
http://www.rvddps.com/apps/sixshot/booking.html
I had a bunch of links to pages but due to my user level i'm only allowed to post one link. You can see the manifest file there and the source code of the page i'm trying to cache.
I've set the correct MIME type on the server, but the cache only seems to work occasionally.. not all the time. I've tried following apples' official caching guidelines as well.
Can anyone point out where i'm going wrong?
Thanks
Daniel
I looked at the manifest file and found 'Â' characters in some of the blank lines. What text editor are you using? Make sure you use the proper encoding and line ending types.

iPhone HTML Parsing using TouchXML and tidy

I'm trying to parse HTML using TouchXML. However, it seems that the data I want to parse (I do not control the source, it's downloaded from the internet) is partially malformed - I get various errors during the parse. Therefore, it seems that I should be using the inbuilt tidy support to fix the HTML but I cannot seem to find any documentation or information on how to enable it or link libtidy successfully into my project.
If anyone has any information on how to do this, it'd be much appreciated. Alternatively if there's another tool I could be using to do this - do tell me!
Actually, you can both link to the framework and include the headers, without needing to download the source.
Link to the existing framework libtidy.dylib
Add /usr/include/tidy to HEADER_SEARCH_PATHS
Turns out that although the framework can be linked in to an xcode project, the headers are missing. I have got around this by downloading the HTML Tidy Source (src and include directory) and added them in to compile as part of my xcode project.

Building libxslt for iPhone

I just had an app rejected for linking to libxslt using this technique.
I'd really like to use XSLT in my app, so it looks like my only shot is to compile it myself. I don't want to use a UIWebView because I want to store the resulting HTML, not just display it.
Has anyone done this -- compiled libxslt for the iPhone?
After some Googling, I've got an old Xcode solution from here and git-cloned the latest libxslt from gnome.org. Neither approach has worked out so far (autoconf bails out, and the Xcode project is missing a bunch of files).
Any advice would be appreciated.
Thanks!
Update 7/21
I found a workaround by giving UIWebView some XML linked to an XSL stylesheet. After the data loads,
I can grab the transformed HTML like this (source):
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
html = [webView stringByEvaluatingJavaScriptFromString:
#"document.documentElement.outerHTML;"];
}
That said, if anyone has any hints on using libxslt directly, I'd love to hear them. Dropping into javascript seems so...unsavory.
You're not allowed to add dylibs, but you can link to a .a file. Can you get the configure for libxslt to output a .a file instead?

iPhone "Web Site Error"

I'm writing server-side programs in PHP for an iPhone app. And I have no iPhone. :P
The iPhone app requests XML files from the site whenever a user runs the iPhone app. You may visit http://www.appvee.com/iphone/ads or http://www.appvee.com/iphone/latest for the XML files.
And a message box will show up with the following error messages:
"Web Site Error
Conversion of data failed. The file is not UTF-8, or in the encoding specified in XML header if XML.
"
Maybe I must add header("Content-type: text/xml"); at the beginning of the PHP files? I didn't add this line and it worked well before.
Any help is greatly appreciated.
I agree with ceejayoz, looks like this is a special characters issue.
I would suggest using the htmlentities method to encode the data in the xml file.
It might be the unescaped special character (looks like it's supposed to be a curly apostrophe) in the 'latest' XML. (in the line that goes "Find out information about what[THIS IS THE CHARACTER]s around you and how...")
Does adding an XML content type header resolve the issue? You ask it if's necessary but give no indication if it helps or not.