Simple libxml2 HTML parsing example, using Objective-c, Xcode, and HTMLparser.h

I used Ben Reeves’ HTML Parser to achieve what I wanted: NSError *error = nil; NSString *html = @”<ul>” “<li><input type=”image” name=”input1″ value=”string1value” /></li>” “<li><input type=”image” name=”input2″ value=”string2value” /></li>” “</ul>” “<span class=”spantext”><b>Hello World 1</b></span>” “<span class=”spantext”><b>Hello World 2</b></span>”; HTMLParser *parser = [[HTMLParser alloc] initWithString:html error:&error]; if (error) { NSLog(@”Error: %@”, error); return; } HTMLNode *bodyNode … Read more

Error to install Nokogiri on OSX 10.9 Maverick?

You can also install Nokogiri on Mac OS X 10.9 Mavericks with full XCode Install using: gem install nokogiri — –with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 Update For those using Yosemite the following command will work: gem install nokogiri — –with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 –use-system-libraries or, it might actually be in your MacOSX10.11.sdk folder (mine was as of 18-Sep-2015) anyways, so even if … Read more

Mac user and getting WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.7.3

If you installed Nokogiri with gem install nokogiri, you can resolve this warning by running gem pristine nokogiri to recompile the gem’s C extension. If you installed Nokogiri with bundle install, you can resolve this warning by running bundle exec gem pristine nokogiri to recompile the C extension of the gem wherever Bundler installed it.

libxml/tree.h no such file or directory

Follow the directions here, under “Setting up your project file.” Setting up your project file You need to add libxml2.dylib to your project (don’t put it in the Frameworks section). On the Mac, you’ll find it at /usr/lib/libxml2.dylib and for the iPhone, you’ll want the /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/usr/lib/libxml2.dylib version. Since libxml2 is a .dylib (not a nice … Read more

How to install lxml on Ubuntu

Since you’re on Ubuntu, don’t bother with those source packages. Just install those development packages using apt-get. apt-get install libxml2-dev libxslt1-dev python-dev If you’re happy with a possibly older version of lxml altogether though, you could try apt-get install python-lxml and be done with it. 🙂