hKit Microformats Toolkit for PHP5

hKit is a simple toolkit for extracting common microformats from a page. The page can be presented as a string or a URL, and the result is handed back as a standard PHP array structure. hKit uses SimpleXML for parsing, and therefore requires PHP5.

hKit has a modular structure, with a simple ‘profile’ for each microformat it supports. As the project is very young (June 2006), the only module currently supported is hCard. You can download the latest version on the right. Let me know if you use it somewhere.

In use

<?php 
    include('hkit.class.php');
    $hKit = new hKit;
    $result = $hKit->getByURL('hcard', 'http://microformats.org/');
    print_r($result);
?>

Updates

22 July 2006 - hKit version 0.5

This release appears small, but includes some significant changes which may have caused some regression. Do let me know if you spot any anomalies. Any test results are welcome. There’s a live version on tools.microformatic.com

In this release:

  • fixed by-ref issue cropping up in PHP 5.0.5
  • fixed a bug with a@title
  • added support for new hCard fn=n optimisation
  • added support for new a.include include-pattern

The a.include pattern is still not quite finalised, but I felt it was worth implementing to see how practical it is to both use and parse. If for any reason a.include doesn’t become official, I’ll be taking it out again.

The new fn=n optimisation says that if n isn’t specified and n cannot be implied from fn, then fn can be assumed to be equal to “fn n” and fn may therefore contain n’s sub-items. Easy, right?

Comments

  1. ยง Eddie Roosenmaallen:

    I believe I’ve found a bug in the default proxy hKit uses for HTML tidying, and I’ve built a workaround in hKit.
    The w3 html tidy proxy does bad things to pages which use document.write to embed new scripts; my hack in loadURL() looks for a “document.write(’<script” and tries to recover the damage. It seems to work for Technorati’s user profiles., I’ve not tested it on others yet.

    You can take a look at my modifications at: http://roosenmaallen.com/?attachment_id=15

Download Latest Version

The latest version can be downloaded from Google Code.

Stay Up-to-date

I publish hKit update feeds in RSS and Atom formats.

Licence

hKit is licensed under a LGPL 2.1 license.