MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //home/cafsindia/wealth_cafsindia_com/bend/xml2array.php
<?php 
	class xml2array {

    function xml2array($xml) {
        if (is_string($xml)) {
            $this->dom = new DOMDocument;
            $this->dom->loadXml($xml);
        }

        return FALSE;
    }

    function _process($node) { 
        $occurance = array();

        foreach ($node->childNodes as $child) {
			echo "nodeName :: $child->nodeName<br/>";
			if(strtoupper($child->nodeName) === "NEWDATASET"){
				$occurance[$child->nodeName]++;
			}            
        }
		print_r($occurance);
		
        if ($node->nodeType == XML_TEXT_NODE) { 
            $result = html_entity_decode(htmlentities($node->nodeValue, ENT_COMPAT, 'UTF-8'),ENT_COMPAT,'ISO-8859-15');
        } else {
            if($node->hasChildNodes()){
                $children = $node->childNodes;
                for ($i=0; $i < $children->length; $i++) {
                    $child = $children->item($i);

                    if ($child->nodeName != '#text') {
                        if($occurance[$child->nodeName] > 1) {
                            $result[$child->nodeName][] = $this->_process($child);
                        } else {
                            $result[$child->nodeName] = $this->_process($child);
                        }
                    } else if ($child->nodeName == '#text') {
                        $text = $this->_process($child);

                        if (trim($text) != '') {
                            $result[$child->nodeName] = $this->_process($child);
                        }
                    }
                }
            } 
        }

        return $result;
    }

    function getResult() {
        return $this->_process($this->dom);
    }
}
?>