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)。请参阅许可证文件以获取更多信息。