diff --git a/src/Reader/MicrodataReader.php b/src/Reader/MicrodataReader.php old mode 100644 new mode 100755 index 1f1e692..ff3be42 --- a/src/Reader/MicrodataReader.php +++ b/src/Reader/MicrodataReader.php @@ -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) {