Extract microdata from HTML using PHP. Based on foolip's MicrodataJS implementation of the Microdata DOM API.
PHP
Latest commit ab03174 Jan 8, 2015 @linclark Merge pull request #14 from hubgit/patch-2
Cache the DOMXPath
Failed to load latest commit information.
src Merge pull request #14 from hubgit/patch-2 Jan 8, 2015
tests Fix nested item overwriting. Sep 3, 2014
.gitignore
.travis.yml Need to test against php 5.3 Jun 12, 2014
LICENSE.txt Move license out to separate file. Jun 14, 2014
README.md Update README.md Jun 15, 2014
composer.json Add license to composer.json. Jun 14, 2014
phpunit.xml.dist

README.md

MicrodataPHP Build Status

Microdata is a syntax for embedding machine-readable metadata in HTML.

MicrodataPHP is a PHP library for extracting microdata from HTML documents. It is inspired by MicrodataJS, which is inspired by the native Microdata DOM API.

Example use:

require 'vendor/autoload.php';

use linclark\MicrodataPHP\MicrodataPhp;

$url = 'http://example.com';
$md = new MicrodataPhp($url);
$data = $md->obj();

// Get a property of a top level item.
print $data->items[0]->properties['name'][0];

// Get a property of a nested item.
print $data->items[0]->properties['hiringOrganization'][0]->properties['name'][0];

Requirements

  • Autoloading (e.g. the autoloader provided by Composer)
  • PHP 5.3+

Check out the 1.x branch for older setups.