PHPackages                             dpb587/microdata-dom - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dpb587/microdata-dom

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

dpb587/microdata-dom
====================

A library extending the PHP DOMDocument to support the Microdata DOM API.

85.7k1PHP

Since Apr 4Pushed 10y ago1 watchersCompare

[ Source](https://github.com/dpb587/microdata-dom.php)[ Packagist](https://packagist.org/packages/dpb587/microdata-dom)[ RSS](/packages/dpb587-microdata-dom/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

microdata-dom.php
=================

[](#microdata-domphp)

[![license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](./LICENSE)[![build](https://camo.githubusercontent.com/ccc538f0ca951c82192e5e6350e649f18db1303c63313337f7556da6679c0780/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6470623538372d63692d6172746966616374732d7075626c69632d75732d656173742d312f6470623538372f6d6963726f646174612d646f6d2e7068702f6d61737465722f6275696c642e737667)](https://camo.githubusercontent.com/ccc538f0ca951c82192e5e6350e649f18db1303c63313337f7556da6679c0780/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6470623538372d63692d6172746966616374732d7075626c69632d75732d656173742d312f6470623538372f6d6963726f646174612d646f6d2e7068702f6d61737465722f6275696c642e737667)[![coverage](https://camo.githubusercontent.com/b750da022fd5c61ed191ef48a1ac137df1b609176f055600c11b8d1ce3c01d41/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6470623538372d63692d6172746966616374732d7075626c69632d75732d656173742d312f6470623538372f6d6963726f646174612d646f6d2e7068702f6d61737465722f636f7665726167652e737667)](https://camo.githubusercontent.com/b750da022fd5c61ed191ef48a1ac137df1b609176f055600c11b8d1ce3c01d41/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6470623538372d63692d6172746966616374732d7075626c69632d75732d656173742d312f6470623538372f6d6963726f646174612d646f6d2e7068702f6d61737465722f636f7665726167652e737667)[![loc](https://camo.githubusercontent.com/0bd9d913cfa42551c00f5d3aa7e5b799eeead3931068e86fa9832486cfb8533f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6470623538372d63692d6172746966616374732d7075626c69632d75732d656173742d312f6470623538372f6d6963726f646174612d646f6d2e7068702f6d61737465722f6c6f632e737667)](./src)

This library extends the native [PHP](http://php.net/) [`DOMDocument`](http://php.net/manual/en/class.domdocument.php) providing methods described by the [Microdata](http://www.w3.org/TR/microdata/) and [DOM API](http://www.w3.org/TR/microdata/#microdata-dom-api) specifications to support finding microdata items and describing their properties. It is well covered by tests and tries to be efficient as it traverses the DOM.

Usage
-----

[](#usage)

For a document with microdata, use `MicrodataDOM\DOMDocument`. It works just like a regular `DOMDocument`, but has the extra microdata accessors. The following example...

```
$dom = new MicrodataDOM\DOMDocument();
$dom->loadHTMLFile('http://dpb587.me/about.html');

// find Person types and get the first item
$dpb587 = $dom->getItems('http://schema.org/Person')->item(0);
echo $dpb587->itemId;

// items are still regular DOMElement objects
printf(" (from %s on line %s)\n", $dpb587->getNodePath(), $dpb587->getLineNo());

// there are a couple ways to access the first value of a named property
printf("givenName: %s\n", $dpb587->properties['givenName'][0]->itemValue);
printf("familyName: %s\n", $dpb587->properties['familyName']->getValues()[0]);

// or directly get the third, property-defining DOM element
$property = $dpb587->properties[3];
printf("%s: %s\n", $property->itemProp[0], $property->itemValue);

// use the toArray method to get a Microdata JSON structure
echo json_encode($dpb587->toArray(), JSON_UNESCAPED_SLASHES) . "\n";

```

Will output something like...

```
http://dpb587.me/ (from /html/body/article/section on line 97)
givenName: Danny
familyName: Berger
jobTitle: Software Engineer
{"id":"http://dpb587.me/","type":["http://schema.org/Person"],"properties":{"givenName":["Danny"],...snip...}

```

Installation
------------

[](#installation)

You can install this library via [`composer`](https://getcomposer.org/)...

```
$ composer install dpb587/microdata-dom

```

Development
-----------

[](#development)

You can find runtime code in [`src`](./src) and test code in [`tests/src`](./tests/src). If you are making changes, you should already have [PHPUnit](https://phpunit.de/) installed before running the tests...

```
$ phpunit

```

Alternatively, have your Concourse execute the tests with your local bits...

```
$ fly execute -c ci/tasks/test.yml -i repo=$PWD -x

```

Builds are publicly accessible on [Travis CI](https://travis-ci.org/dpb587/microdata-dom.php) and internally with [Concourse](https://concourse.ci/).

References
----------

[](#references)

You might find these specifications useful...

- [W3C DOM4](http://www.w3.org/TR/dom/)
- [HTML5](http://www.w3.org/TR/html5/)
- [HTML Microdata](http://www.w3.org/TR/microdata/)

License
-------

[](#license)

[MIT License](./LICENSE)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d3ea9bcb7b2f0fa920ad0f222b9037585d5bab8013bd4c2b2dd5fef2ae78baf9?d=identicon)[dpb587](/maintainers/dpb587)

---

Top Contributors

[![dpb587](https://avatars.githubusercontent.com/u/207601?v=4)](https://github.com/dpb587 "dpb587 (2 commits)")

### Embed Badge

![Health badge](/badges/dpb587-microdata-dom/health.svg)

```
[![Health](https://phpackages.com/badges/dpb587-microdata-dom/health.svg)](https://phpackages.com/packages/dpb587-microdata-dom)
```

###  Alternatives

[kartik-v/yii2-widget-rating

A Yii2 widget for the simple yet powerful bootstrap-star-rating plugin with fractional rating support (sub repo split from yii2-widgets)

474.3M8](/packages/kartik-v-yii2-widget-rating)[statamic/seo-pro

68488.6k](/packages/statamic-seo-pro)[laramall/laravel-system-info

查看服务器所有信息 system info

311.0k1](/packages/laramall-laravel-system-info)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
