Updated usage section in README
This commit is contained in:
		
							
								
								
									
										41
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								README.md
									
									
									
									
									
								
							@@ -21,9 +21,44 @@ $ composer require yusufkandemir/microdata-parser
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
## Usage
 | 
					## Usage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
``` php
 | 
					##### PHP
 | 
				
			||||||
$parser = new YusufKandemir\MicrodataParser();
 | 
					```php
 | 
				
			||||||
$microdata = $parser->extractMicrodata();
 | 
					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 as HTML
 | 
				
			||||||
 | 
					```html
 | 
				
			||||||
 | 
					<!-- 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>
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					##### Result as JSON
 | 
				
			||||||
 | 
					```json
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "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" ]
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  ]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Change log
 | 
					## Change log
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user