PHP, Web Programming

A working Microformats extension to SimpleXML

<![CDATA[I've completed a basic version of a class that (sort of) extends SimpleXML. When I say sort of I mean it extends a wrapper class (ExtendXML) that inlcludes all the functionality of SimpleXML.

Download the following to try it out:

MicroformatXML
ExtendXML

The object is created the same way as ExtendXML. After creating it you must also call:

// $mf is a MicroformatXML object
$mf->mf_init();

This adds a new property, $mfHCards, which is an array of hCards. You can access the various hCard values as properties of these objects. As an example:

$mf = MicroformatXML::create_from_file($xmlFile);
$mf->mf_init();
foreach ($mf->mfHCards as $hCard) {
    print $hCard->fn .'
'; }

Please note this is a very early version that is undocumented and largely untested. It also doesn’t contain every hCard property.

hCard, microformats, XML, SimpleXML, extending SimpleXML, PHP5]]>

Advertisements

One thought on “A working Microformats extension to SimpleXML

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s