//xml document parser 

function xmlParser(){
this.arrayList =  Array();
var xmlObj;
var selectedNodeList ;
this.version ="xmlParser beta 1.0.0";
}

xmlParser.prototype.getDomXml = function(xmlFile){
	this.xmlObj = Sarissa.getDomDocument();
	//alert(this.xmlObj);
	//alert(xmlFile);
	this.xmlObj.async = false;
	var objDom=this.xmlObj;	
	try{objDom.load(xmlFile);}catch(e){alert(e+"xml文件出错或者您没有安装xml解析器");}
}

xmlParser.prototype.getNodeList = function(xPathString){
//	alert(xPathString);
	try
	{
		//alert(this.xmlObj);
		this.selectedNodeList = this.xmlObj.selectNodes(xPathString);	
	}
	catch (e)
	{
		alert(e);
	}
//alert(this.selectedNodeList.item(0).xml);
	return this.selectedNodeList;
}

xmlParser.prototype.dumpNodeList = function(nodeList,opType){
	var count = nodeList.length;
	for(var i=0;i<count;i++){
		if(node = nodeList.item(i)){
			//alert(node.xml);
			this.dumpNode(node,opType);
		}
	}
}


xmlParser.prototype.dumpNode = function(node,opType){	//optype=1----dump_all(include child items)  optype=0--dump current node
	var count;
	var k,v;
	count = this.arrayList.length;
	if(node.hasChildNodes){
		var list = 	node.childNodes;
		this.arrayList[count] = new Array();
		for(var i=0;i<list.length;i++){
			childNode = list.item(i);		
			
			if(childNode.tagName!="COLUMNS"){
				k = childNode.tagName;
				if(childNode.firstChild!=null)
				{
					//alert(k+"fff");
					v = childNode.firstChild.nodeValue;
				}
				else
					v = "";
				this.arrayList[count][k] = v;
			}
			else if(childNode.tagName=="COLUMNS" && opType==1){				
				this.dumpNode(childNode,opType);
				//alert(this.arrayList.length);			
				//break;
			}		
			
		}
	}	
}




























/* backup
//xml document parser 

function xmlParser(){
this.arrayList =  Array();
var xmlObj;
var selectedNodeList ;
this.version ="xmlParser beta 1.0.0";
}

xmlParser.prototype.getDomXml = function(xmlFile){
	this.xmlObj = Sarissa.getDomDocument();
	//alert(this.xmlObj);
	//alert(xmlFile);
	this.xmlObj.async = false;
	var objDom=this.xmlObj;	
	try{objDom.load(xmlFile);}catch(e){alert(e+"xml文件出错或者您没有安装xml解析器");}
}

xmlParser.prototype.getNodeList = function(xPathString){
//	alert(xPathString);
	try
	{
		//alert(this.xmlObj);
		this.selectedNodeList = this.xmlObj.selectNodes(xPathString);	
	}
	catch (e)
	{
		alert(e);
	}
//alert(this.selectedNodeList.item(0).xml);
	return this.selectedNodeList;
}

xmlParser.prototype.dumpNodeList = function(nodeList,opType){
	var count = nodeList.length;
	for(var i=0;i<count;i++){
		if(node = nodeList.item(i)){
			//alert(node.xml);
			this.dumpNode(node,opType);
		}
	}
}


xmlParser.prototype.dumpNode = function(node,opType){	//optype=1----dump_all(include child items)  optype=0--dump current node
	var count;
	var k,v;
	count = this.arrayList.length;
	if(node.hasChildNodes){
		var list = 	node.childNodes;
		this.arrayList[count] = new Array();
		for(var i=0;i<list.length;i++){
			childNode = list.item(i);			
			//alert(childNode.xml+i);
			if(childNode.tagName!="COLUMNS"){
				k = childNode.tagName;
				v = childNode.text;
				alert(v);
				alert(k);
				this.arrayList[count][k] = v;
			}
			else if(childNode.tagName=="COLUMNS" && opType==1){				
				this.dumpNode(childNode,opType);
				//alert(this.arrayList.length);			
			
			}		
			
		}
	}	
}
*/