<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mac / iPhone App Development &#187; html parser</title>
	<atom:link href="http://benreeves.co.uk/tag/html-parser/feed/" rel="self" type="application/rss+xml" />
	<link>http://benreeves.co.uk</link>
	<description>Home of a Small Time Developer</description>
	<lastBuildDate>Wed, 26 May 2010 14:24:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Objective C HMTL Parser</title>
		<link>http://benreeves.co.uk/objective-c-hmtl-parser/</link>
		<comments>http://benreeves.co.uk/objective-c-hmtl-parser/#comments</comments>
		<pubDate>Sat, 08 May 2010 13:03:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[html parser]]></category>
		<category><![CDATA[libxml]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[uiwebview]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://benreeves.co.uk/?p=286</guid>
		<description><![CDATA[Here is basic html parser which I&#8217;ve used in several projects recently. The code depends on libxml2 and is basically a thin wrapper that provides a more convenient interface for parsing html with objective c. This has only been tested on iphone OS 3.1.3 &#38; 3.2, if your using a OSX your probably better of [...]]]></description>
			<content:encoded><![CDATA[<p>Here is basic html parser which I&#8217;ve used in several projects recently. The code depends on <a href="http://xmlsoft.org/">libxml2</a> and is basically a thin wrapper that provides a more convenient interface for <strong>parsing html with objective c. </strong>This has only been tested on iphone OS 3.1.3 &amp; 3.2, if your using a OSX your probably better of investigating using Webkit to manipulate your DOM.</p>
<p>The code below is provided under an MIT license, but if you do make any updates it would be great if you could send them back.</p>
<p>Usage:</p>
<pre lang="objc">   //Example to download google's source and print out the urls of all the images
   NSError * error = nil;
   HTMLParser * parser = [[HTMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com"] error:&amp;error];

   if (error) {
     NSLog(@"Error: %@", error);
     return;
  }
  HTMLNode * bodyNode = [parser body]; //Find the body tag

  NSArray * imageNodes = [bodyNode findChildTags:@"img"]; //Get all the <img alt="" />

 for (HTMLNode * imageNode in imageNodes) { //Loop through all the tags
       NSLog(@"Found image with src: %@", [imageNode getAttributeNamed:@"src"]); //Echo the src=""
  }

  [parser release];</pre>
<p><strong>You can grab a copy of the code here on github:</strong><br />
<a href="http://github.com/zootreeves/Objective-C-HMTL-Parser ">http://github.com/zootreeves/Objective-C-HMTL-Parser</a><br />
git@github.com:zootreeves/Objective-C-HMTL-Parser.git</p>
<h4>Note:</h4>
<p>-(NSString*)rawContents; does not work, you need to use NSString * rawContentsOfNode(xmlNode * node, htmlDocPtr doc); to dump the entire html contents of a node.</p>
]]></content:encoded>
			<wfw:commentRss>http://benreeves.co.uk/objective-c-hmtl-parser/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

