XML

A working Microformats extension to SimpleXML

Oliver Brown
— This upcoming video may not be available to view yet.

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:

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.

Issues with extending SimpleXML

Oliver Brown
— This upcoming video may not be available to view yet.

I wrote a post about my attempts to extend SimpleXML to support microformats. Well it’s not as it easy as it seems.

You can’t define new properties of a class extending SimpleXMLElement. Well you can define them but they don’t work - when you access them they always return a SimpleXMLElement object (or actually an object of whatever class you defined).

I’ve tried overriding __get and __set and neither work so the only thing I can think of is to create a new class that delegates most of it’s work to SimpleXMLElement.

Fun with XML

Oliver Brown
— This upcoming video may not be available to view yet.

Have a look at:

http://www.oliverbrown.me.uk/vocab/reading/en-fi-1.xml.

You will need a fairly new browser to see this properly.

Whether I can be bothered to make a whole website out of this, mirroring (and possible helping) my own attempt to learn Finnish, who knows…

More XFN

Oliver Brown
— This upcoming video may not be available to view yet.

Well if you have a URL you want crawled go to http://brownab1.miniserver.com/xfn/crawl.php.

If you want to have a look at the pages already there in a nice graphical network display, go to http://brownab1.miniserver.com/xfn/image.php.

This displays 26 random sites and the links between them. If you click on a site it “holds” it so subsequent requests always contain this site (this way you can slowly buildup an image of sites that actually link to each other).

Pretty XFN

Oliver Brown
— This upcoming video may not be available to view yet.

XFN stands for XML Friends Network. You basically define human relationships between webpage authors by adding an extra atribute to links.

Well I decded to write a nice XFN crawler/search engine thingy. The crawler part works. I also decided to do a nice graphical representation of the links between sites.

Red is “crush”, blue is “met” and green is “friend” (just three properties I picked at random).

XFN Network