PHP code example of slub / php-mods-reader
1. Go to this page and download the library: Download slub/php-mods-reader 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/ */
slub / php-mods-reader example snippets
$modsReader = new ModsReader($this->xml);
// get all titleInfo elements
$titleInfos = $modsReader->getTitleInfos();
// get first titleInfo element
$firstTitleInfo = $modsReader->getFirstTitleInfo();
// get first titleInfo element
$lastTitleInfo = $modsReader->getLastTitleInfo();
// get name elements which match to give string query
$authors = $modsReader->getNames('[./mods:role/mods:roleTerm[@type="code" and @authority="marcrelator"]="aut"]');
// get nameIdentifier for first name element if its type attribute is equal to 'orcid'
$identifier = $authors[0]->getNameIdentifier('[@type="orcid"]');
// get string value of element
$value = $identifier->getValue();
// get 'type' attribute of element
$type = $identifier->getType();
// get child elements of element
$places = [];
$originInfos = $this->modsReader->getOriginInfos('[not(./mods:edition="[Electronic ed.]")]');
foreach ($originInfos as $originInfo) {
foreach ($originInfo->getPlaces() as $place) {
foreach ($place->getPlaceTerms() as $placeTerm) {
$places[] = $placeTerm->getValue();
}
}
}