Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Reader/MicrodataReader.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public function read(DOMDocument $document, string $url) : array
$xpath = new DOMXPath($document);

/**
* An item is a top-level Microdata item if its element does not have an itemprop attribute.
* An item is a top-level Microdata item if its element does not have an itemprop attribute or
* if it is the mainEntity of the page.
*
* https://www.w3.org/TR/microdata/#associating-names-with-items
*/
$nodes = $xpath->query('//*[@itemscope and not(@itemprop)]');
$nodes = $xpath->query('//*[@itemscope and (not(@itemprop) or @itemprop="mainEntity")]');
$nodes = iterator_to_array($nodes);

return array_map(function(DOMNode $node) use ($xpath, $url) {
Expand Down