Søren Johannessen von Microformats.dk hat auf seinem Weblog ein Exclusiv-Interview mit Brian Suda zum Thema „Microformats“ geführt.

Brian: I like to talk about microformats as “semantic sugar”. Everyone can understand that adding a little bit of sugar to your food you make it taste better. Adding microformats into your HTML makes it “taste” a little better too!

Ein weiterer interessanter Artikel von Brian Suda über Portable Social Networks: Take Your Friends with You.

Here are some code snippets to use the gorgeous X2V microformats XSLT files from Brian Suda with PHP 5 and libxslt (PHP 5 includes the XSL extension by default).

hCard to vCard:

To parse a XML or XHTML document, it has to be valid. To tidy the XML file, you can use a service from the W3C:

$xml_string_tidy = file_get_contents("http://cgi.w3.org/cgi-bin/tidy?docAddr=".urlencode($uri));

Then you have to create the HTML DOM…

@$document = new DOMDocument();

and the XSLT DOM…

$stylesheet = new DOMDocument();

Create a new XSLT Processor, load the Stylesheet…

$processor = new XsltProcessor();

and run the transformation.

$result = $processor->transformToDoc($document);
$str = $result->saveXML();

Now $str contains the transformed code.
To send the vCard header with PHP, try

header("Content-Disposition: attachment; filename=contact.vcf");
header("Content-Type: text/x-vcard; charset=UTF-8 name=contact.vcf");
echo $str;

If you want to use the vCard extension .vcf instead of .php you have to add something like that to your .htaccess file

RewriteEngine On
RewriteBase /
RewriteRule ^contact.vcf /hcard2vcard.php [L,QSA]

I hope it works :)