Forum Moderators: coopster
<?php
$rss = new SimpleXMLElement("http://$fqdn/rss/FreeDownloads.xml", null, true);
foreach($rss->xpath("channel/item") as $item) {
$filename = basename($item->guid,".xml");
echo $filname;
}
?>
<?php
$articles = array();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<?php
foreach($articles as $key => $val) {
echo "articles[".$key."] = ".$val."\n";
}
?>
<?php
$rss = new SimpleXMLElement("http://$fqdn/rss/FreeDownloads.xml", null, true);
foreach($rss->xpath("channel/item") as $item) {
$articles[] = $item->title;
$filename = basename($item->guid,".xml");
echo $filename;
}
?>
I thought it was odd when Readie said to build it at the top.
<?php
/**
* 1. Declare/initialise your variables
* Or at least the ones that *need* to be initialised
*/
$articles = array();
$files = array();
/**
* 2. Assign values to your variables
*/
$rss = new SimpleXMLElement("http://$fqdn/rss/FreeDownloads.xml", null, true);
foreach($rss->xpath("channel/item") as $item) {
$articles[] = $item->title;
$files[] = basename($item->guid,".xml");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<pre>
<?php
/**
* 3. Output
*/
print_r($articles);
print_r($files);
?>
</pre>
</body>
</html>
Array
(
[0] => SimpleXMLElement Object
(
[title] => The Life Of Praise
[description] => SimpleXMLElement Object
(
)
[guid] => [moorelife.org...]
[pubDate] => Fri, 24 Sep 2004 19:30:00 CST
[category] => Victory
)
[1] => SimpleXMLElement Object
(
[title] => Faith And Patience
[description] => SimpleXMLElement Object
(
)
[guid] => [moorelife.org...]
[pubDate] => Thu, 14 Oct 1999 10:00:00 CST
[category] => Faith
)
$rss = simpledom_load_file("http://www.moorelife.org/rss/FreeDownloads.xml");
foreach($rss->sortedXPath('channel/item', 'title') as $item) {
$filename = basename($item->guid,".xml");
echo <<<END
<li><a href="#$filename">$item->title</a></li>\n
END;
}