implementation-guidelines

From Microformats Wiki
Revision as of 04:01, 30 July 2005 by MarkRickerby (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Guidelines and Strategies for Implementing Microformats

Identification

Javascript/XPath example which runs in Mozilla:

var mf = 'hreview';

var micropath = "//*[contains(@class,'" + mf + "')]";
var micromatch = new RegExp('\\b' + mf + '\\b');

var mc = document.evaluate(micropath, document, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < mc.snapshotLength; i++) {
    iNode = mc.snapshotItem(i);
    if (iNode.className.match(micromatch))
        doSomething();
}