PHP code example of einfacharchiv / microdata
1. Go to this page and download the library: Download einfacharchiv/microdata library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
einfacharchiv / microdata example snippets
$html = '<!doctype html><html lang="en"><head>...';
$microdata = new Microdata($html);
// Get all invoice items
foreach ($microdata->getItemsByType('Invoice') as $item) {
// Available methods
(string) $item->getBillingPeriod() ?: null;
$item->getConfirmationNumber();
if ($item->getCustomer()) {
(string) $item->getCustomer()->getIdentifier() ?: null;
$item->getCustomer()->getName();
if ($item->getCustomer()->getAddress()) {
$item->getCustomer()->getAddress()->getStreetAddress();
$item->getCustomer()->getAddress()->getPostOfficeBoxNumber();
$item->getCustomer()->getAddress()->getPostalCode();
$item->getCustomer()->getAddress()->getAddressLocality();
$item->getCustomer()->getAddress()->getAddressRegion();
(string) $item->getCustomer()->getAddress()->getAddressCountry() ?: null;
}
$item->getCustomer()->getEmail();
$item->getCustomer()->getTelephone();
$item->getCustomer()->getUrl();
$item->getCustomer()->getTaxId();
$item->getCustomer()->getVatId();
}
(string) $item->getPaymentDueDate() ?: null;
(string) $item->getPaymentMethod() ?: null;
$item->getPaymentMethodId();
(string) $item->getPaymentStatus() ?: null;
if ($item->getProvider()) {
$item->getProvider()->getName();
if ($item->getProvider()->getAddress()) {
$item->getProvider()->getAddress()->getStreetAddress();
$item->getProvider()->getAddress()->getPostOfficeBoxNumber();
$item->getProvider()->getAddress()->getPostalCode();
$item->getProvider()->getAddress()->getAddressLocality();
$item->getProvider()->getAddress()->getAddressRegion();
(string) $item->getProvider()->getAddress()->getAddressCountry() ?: null;
}
$item->getProvider()->getEmail();
$item->getProvider()->getTelephone();
$item->getProvider()->getUrl();
$item->getProvider()->getTaxId();
$item->getProvider()->getVatId();
}
if ($item->getTotalPaymentDue()) {
$item->getTotalPaymentDue()->getAmount(); // Returns an array with 'amount' and 'currency'
}
(string) $item->getIdentifier() ?: null;
$item->getName();
$item->getUrl();
}