microdata parser
v1.0.1
該套件旨在實現 W3C 微資料到 JSON 規範。
微數據解析器從文件中提取微數據。
透過作曲家
$ composer require yusufkandemir/microdata-parser
use YusufKandemir MicrodataParser Microdata ;
$ microdata = Microdata:: fromHTMLFile ( ' source.html ' )-> toJSON ();
/* Other sources:
fromHTML() // from HTML string
fromDOMDocument() // from DOMDocument object
Other output methods:
toArray() // to Associtive PHP Array
toObject() // to PHP Object (stdClass)
*/
<!-- source.html -->
< div itemscope itemtype =" http://schema.org/Product " >
< img itemprop =" image " src =" http://shop.example.com/test_product.jpg " />
< a itemprop =" url " href =" http://shop.example.com/test_product " >
< span itemprop =" name " > Test Product </ span >
</ a >
</ div >
{
"items" : [
{
"type" : [ " http://schema.org/Product " ],
"properties" : {
"image" : [ " http://shop.example.com/test_product.jpg " ],
"url" : [ " http://shop.example.com/test_product " ],
"name" : [ " Test Product " ]
}
}
]
}
$ composer test
詳細資訊請參閱貢獻。
麻省理工學院許可證 (MIT)。請參閱許可證文件以獲取更多資訊。