<?php
$localstore = "/var/root/rss.xml";

# ファイルからDOMを生成
$doc = new DOMDocument();
$doc->load($localstore);

# XPathの準備
$xpath = new DOMXPath($doc);
$xpath->registerNamespace('rss', $doc->documentElement->lookupNamespaceURI(null));

# フィードのタイトル
$feed_title = htmlspecialchars($xpath->query('rss:channel/rss:title')->item(0)->nodeValue);
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>フィードリーダー</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<style type="text/css" media="screen">@import "iui/iui.css";</style>
<script type="application/x-javascript" src="iui/iui.js"></script>
<body>
    <div class="toolbar">
        <h1 id="pageTitle"></h1>
        <a id="backButton" class="button" href="#"></a>
        <a class="button" href="loader.php" target="_self">読み込み</a>
    </div>
        <ul id="feed1" title="<?php print $feed_title ?>" selected="true">
<?php
#フィードのアイテムを取り出す
$index = 0;
$items = $xpath->query('//rss:item');
foreach($items as $item) {
    # アイテムの中からタイトルやリンクを取りだす
    $title = htmlspecialchars($xpath->query('rss:title', $item)->item(0)->nodeValue);
    $link = htmlspecialchars($xpath->query('rss:link', $item)->item(0)->nodeValue);
    $description = htmlspecialchars($xpath->query('rss:description', $item)->item(0)->nodeValue);

    printf( '<li><a href="#feed1_%d" ><nobr style="overflow:hidden; display: block">%s</nobr></a></li>', $index, $title );
    $html = sprintf('%s<div id="feed1_%d" title="%s" class="panel" ><a href="%s" target="_self">%s</a><p>%s<p></div>', $html, $index, $title, $link, $title, $description);
    $index += 1;
}
print "</ul>";
print $html;
?>
</body>
</html>