<?php
class netsXml extends netsError {
	public $sXmlVersion='1.0';
	public $sXmlRoot='netsRoot';
	public $sXmlRow='netsRow';
	
	public function netsXml(){
		$this->netsError();
	}
	
	public function makeDataToXml($pCollection){
		$tmpSTR='';
		
		$tmpDom=new DomDocument($this->sXmlVersion);
		$tmpRoot=$tmpDom->createElement($this->sXmlRoot);
		$tmpDom->appendChild($tmpRoot);
		$Coun0=0;
		foreach($pCollection as $Row0){
			$tmpRow=$tmpDom->createElement($this->sXmlRow);
			$tmpRow->setAttribute('index',$Coun0);
			$tmpRoot->appendChild($tmpRow);
			while($tmpAR0=each($Row0)){
				$tmpColumn=$tmpDom->createElement($tmpAR0['key']);
				$tmpTextNode=$tmpDom->createTextNode($tmpAR0['value']);
				$tmpColumn->appendChild($tmpTextNode);
				$tmpRow->appendChild($tmpColumn);
			}
			$Coun0++;
		}

		$tmpSTR=$tmpDom->saveXml();
		return $tmpSTR;
	}
	public function makeNETSXML($pData){
		$tmpSTR='';
		
		$tmpDom=new DomDocument($this->sXmlVersion);
		$tmpRoot=$tmpDom->createElement($this->sXmlRoot);
		$tmpDom->appendChild($tmpRoot);
		
		$Coun0=0;
		foreach($pData as $Row0){
			$tmpRow=$tmpDom->createElement($this->sXmlRow);
			$tmpRoot->appendChild($tmpRow);
			
			$tmpColumn=$tmpDom->createElement('Name');
			$tmpTextNode=$tmpDom->createTextNode($Row0[0]);
			$tmpColumn->appendChild($tmpTextNode);
			$tmpRow->appendChild($tmpColumn);
			$tmpColumn=$tmpDom->createElement('Type');
			$tmpTextNode=$tmpDom->createTextNode($Row0[1]);
			$tmpColumn->appendChild($tmpTextNode);
			$tmpRow->appendChild($tmpColumn);
			if(is_array($Row0[2])){
				$tmpColumn=$tmpDom->createElement('Value');
				foreach ($Row0[2] as $Row1){
					$tmpDataRow=$tmpDom->createElement('dataRow');
					while($Row_This=each($Row1)){
						$tmpDataColumn=$tmpDom->createElement($Row_This['key']);
						$tmpTextNode=$tmpDom->createTextNode($Row_This['value']);
						$tmpDataColumn->appendChild($tmpTextNode);
						$tmpDataRow->appendChild($tmpDataColumn);
					}
					$tmpColumn->appendChild($tmpDataRow);
				}
				$tmpRow->appendChild($tmpColumn);
			}else {
				$tmpColumn=$tmpDom->createElement('Value');
				$tmpTextNode=$tmpDom->createTextNode($Row0[2]);
				$tmpColumn->appendChild($tmpTextNode);
				$tmpRow->appendChild($tmpColumn);
			}
			$tmpColumn=$tmpDom->createElement('Message');
			$tmpTextNode=$tmpDom->createTextNode($Row0[3]);
			$tmpColumn->appendChild($tmpTextNode);
			$tmpRow->appendChild($tmpColumn);
			
			$Coun0++;
		}
		
		$tmpSTR=$tmpDom->saveXml();
		return $tmpSTR;
	}
}
?>