- simplexml_load_file: documentation ( source)
<html>
<head>
<style>
body{
background-color: #95a5a6;
}
</style>
<title>
Random Cats
</title>
<meta charset="utf-8" />
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js">
</script>
<style>
body{
background-color: #95a5a6;
}.img-thumbnail{
-moz-box-shadow: 3px 3px 5px 6px grey;
-webkit-box-shadow: 3px 3px 5px 6px grey;
box-shadow: 3px 3px 5px 6px grey;
}
</style>
</head>
<body>
<center>
<h1>
Random Cats *.*
</h1>
<?php
$url = "http://thecatapi.com/api/images/get?format=xml&results_per_page=1";
$xml = simplexml_load_file($url);
$xmlImg = $xml->data->images->image->url;
$xmlImgSource = $xml->data->images->image->source_url;
$source = $xmlImgsource;
echo "
<img src='$xmlImg' width='600px' class='img-thumbnail'>
"
?>
<br>
<br>
<div>
<a href="
<?php echo $xmlImgSource ?>
">
<button class="button">
Source
</button>
</a>
<a href="/">
<button type="submit" class="button">
New Picture
</button>
</a>
</div>
<br>
<p>
Original made by Nihad Dizdarevic
<br>
TheCatAPI & XML
</p>
<a href="https://github.com/dizzyniho/TheCatsSite">
Fork this on GitHub
</a>
</center>
</body>
</html>