load("https://api-na.hosted.exlibrisgroup.com/almaws/v1/conf/libraries/DKL/open-hours?apikey=l7xx319d803f314b4eab803da6fae5aaee7e"); $end = $xmlDoc->getElementsByTagName('to'); $start = $xmlDoc->getElementsByTagName('from'); $hours = $xmlDoc->getElementsByTagName('hours'); $date = $xmlDoc->getElementsByTagName('date'); $day = $xmlDoc->getElementsByTagName('day'); echo "
"; $today = new DateTime(); $tomorrow = new DateTime('+1 day'); $day3 = new DateTime('+2 day'); $day4 = new DateTime('+3 day'); $day5 = new DateTime('+4 day'); $day6 = new DateTime('+5 day'); $day7 = new DateTime('+6 day'); $day8 = new DateTime('+7 day'); $interval = new DateInterval('P1D'); echo $today->format('D, M d') . ":
"; echo $tomorrow->format('D, M d') . ":
"; echo $day3->format('D, M d') . ":
"; echo $day4->format('D, M d') . ":
"; echo $day5->format('D, M d') . ":
"; echo $day6->format('D, M d') . ":
"; echo $day7->format('D, M d') . ":
"; echo $day8->format('D, M d') . ":
"; //echo date("D") . "
"; //echo date("D+1") . "
"; echo "
"; /*echo "
"; foreach ($date as $date) { $mdy = $date->nodeValue; echo $mdy = substr($mdy, 5, -1) . "-" . substr($mdy, 0, 4) . "
" ; //echo $date->nodeValue, PHP_EOL . "
" ; // Prints something like: Monday } echo "
";*/ echo "
"; foreach ($hours as $hours) { if (!empty($hours->nodeValue)) { //echo $hours->nodeValue, PHP_EOL . "
" ; $str = $hours->nodeValue; echo $str = substr($str, 0, 2) . substr($str, 3, -5) . ' - ' . substr($str, 5, -3). substr($str, 8) . "
" ; } else { echo 'Closed' . "
"; } } echo "
"; /*foreach ($end as $end) { echo $end->nodeValue, PHP_EOL . "
" ; }*/ echo ""; //print $xmlDoc->saveXML(); /* $x = $xmlDoc->documentElement; $hours = $xmlDoc->getElementsByTagName('to'); $start = $xmlDoc->getElementsByTagName('from'); foreach ($x->childNodes AS $item) { print $item->nodeName . " = " . $item->nodeValue . "
"; } */ $xml_content = file_get_contents('https://api-na.hosted.exlibrisgroup.com/almaws/v1/conf/libraries/DKL/open-hours?apikey=l7xx319d803f314b4eab803da6fae5aaee7e'); $xml = simplexml_load_string($xml_content); //echo $xml_content; /*$xml->getElementsByTagName('day'); echo ("
"); $day->getElementsByTagName('date')->childNodes->nodeValue; echo ("
");*/ //shows one day of xml data //print_r($xml->day); ?>