WMDI: Mad Scientist Experiments v.01
I’ve been remiss in my participatin regading the The Weblog MetaData Initiative: Next Step: HTML [meta] Experiment. Even after NZ mentions me by name! At Dean’s suggestion, I’ve gone ahead and taken a rather quick-and-dirty approach to our encoding problem. I’ve developed a specification which shows how to encode our general schema’s metadata using only HTML [meta] tags. Along the way, I’ve also “Dublin Core-ized” our data schema, and tried to use DC tags wherever possible and appropriate.
But because some of you are not programmers, and because some of you don’t have a clue what I’m talking about, I’m going to offer two ‘baby-steps’ parsers that show how to take a WMDI encoded page and display the various tags. Even if you’re not into the WMDI, you may find these parsing mechanism useful:
First in Perl (console version)
use LWP::Simple;
$url = “http://www.truthlaidbear.com/001388.html”;
$text = get($url);
unless (defined $text)
{ die(”ERROR * Cannot Load $url - $!”) }
use HTML::TokeParser;
$parser=HTML::TokeParser->new(\$text);
while (my $token=$parser->get_tag(”meta”))
{
print $token->[1]{name}.” -> “.$token->[1]{content}.”\n”
if $token->[1]{name} =~ m/^(DC|WMDI)\./i;
}
Now PHP
$url = “http://www.truthlaidbear.com/001388.html”;
$metatags = @get_meta_tags(”$url”,1);
if (!$metatags) $metatags=@get_meta_tags(”$url/”,1);
while (list($name, $contents) = each($metatags))
{
if (eregi(”^(dc|wmdi)_”, $name)) {
$tags = split(”_”, $name);
$type = array_shift($tags);
$tag = join(”.”, $tags);
echo “$type: <b>$tag</b> - $contents\n<br />”;
}
}
?>
There, now that wasn’t so painful was it?










