/*###################################
#
#		ニュースのXMLを取得して一覧を書き出し
#
#			2011.2.2    takuya fujioka
#
###################################*/

// XMLを取得
function getNews( xmlUrl , limit ){
	$.ajax({
		url: xmlUrl,
		dataType: "xml",
		success: xmlParser,
		error: function(){alert('XMLファイルが読み込めませんでした')}
	});
	function xmlParser( xml ) {
		// XMLの中身を整形して書き出し
		$( xml ).find( 'item' ).each( function(i){
			var date = $(this).find( 'date' ).text();
			var title = $(this).find( 'title' ).text();
			var id = $(this).find( 'id' ).text();

			$('#newsList').append(
				'<li><span class="date">'+ date +'</span><a href="news.html?id='+ id +'">'+ title +'</a></li>'
			);

			i++

			// 書き出し最大数を超えたらブレイク
			if( i >= limit ){
				return false;
			};
		});
	}
}

