Last active
October 22, 2015 15:31
-
-
Save johnmorris/37f9e96655353c5b70c5 to your computer and use it in GitHub Desktop.
How to parse XML using SimpleXML and PHP (Tutorial: http://www.johnmorrisonline.com/how-to-parse-xml-with-simplexml-and-php/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>How to Parse XML With SimpleXML and PHP</title> | |
</head> | |
<body> | |
<?php | |
$url = 'http://www.johnmorrisonline.com/feed/'; | |
$xml = simplexml_load_file($url) or die("Can't connect to URL"); | |
?><pre><?php print_r($xml); ?></pre><?php | |
foreach ($xml->channel->item as $item ) { | |
printf('<li><a href="%s">%s</a></li>', $item->link, $item->title); | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment