Ejemplo n.º 1
0
// include xml library
include_once 'lib.xml.inc.php';
// convert an rdf item to an associative array
function asArray($item)
{
    $a = array();
    while ($item) {
        $a[$item->nodeName] = $item->firstChild->nodeValue;
        $item = $item->nextSibling;
    }
    return $a;
}
// get the feed
$rss = new _XML('http://sourceforge.net/export/rss2_projsummary.php?group_id=84936');
// get article items
$items = $rss->getElementsByTagName('item');
// loop through items and gather download info
$downloads = 1270;
foreach ($items as $k => $item) {
    $a = asArray($item->firstChild);
    if (preg_match("/Downloadable\\ files\\: (\\d+)\\ total\\ downloads/is", $a['title'], $matches)) {
        $downloads += $matches[1];
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title>phpdomxml-0.9.0 test / example batches</title>
	<meta http-equiv="content-type" content="text/html;charset=utf-8" />