<!--

// XMLファイルを書き換えるだけで
// テーブルを書き換えられます。

//テーブルを出力するDIVのID名
var outputDivId = 'tdiv'


//====================================================================
// Ajax処理
//

var dataAry            //データ配列

//リクエスト送信
function setData(dataFileName)
{
	sendRequest(onloaded,'','GET',dataFileName,true,true)
}

//受信時処理
function onloaded(res)
{
	xmldoc = res.responseXML
	dataAry = Xml2Ary(xmldoc)
	writeTable(outputDivId,dataAry)
}

//responseXMLで受け取ったデータを2次元配列化して返します
function Xml2Ary(xmldoc)
{
	//ヘッダ行の列データを2列分(名前と科目名)セットします
	var th1 = xmldoc.getElementsByTagName('th')[0] ;
	var th2 = xmldoc.getElementsByTagName('th')[1] ;
	
	//itemとnameとtenの配列をセットします
	var items  = xmldoc.getElementsByTagName('item') ;
	var names  = xmldoc.getElementsByTagName('name') ;
	var tens   = xmldoc.getElementsByTagName('ten') ;

	//作業用配列
	var dataArywk = [] ;
	//ヘッダ行を配列化して追記
	dataArywk.push([ th1.firstChild.nodeValue , th2.firstChild.nodeValue]) ;
	//データ行を配列化して追記
	for(i=0 ; i <= items.length-1 ; i++){
		dataArywk.push([ names[i].firstChild.nodeValue 
		               , tens[i].firstChild.nodeValue]) ;
	}
	return dataArywk ;
}

//-->
