The template package has been imported recently. The template package contains xml files and needs to be parsed into a given php array format. I have come across two methods, namely the DOMDocument method and simple_load_file. personal preference. This is simple. The following describes the usage of $ template_config_pathmodule_1.xml; functionpar
The template package has been imported recently. The template package contains xml files and needs to be parsed into a given php array format. I have come across two methods, namely the DOMDocument method and simple_load_file. personal preference. This is simple. The following describes the usage of $ template_config_path = 'module _ 1. xml'; function par
The template package has been imported recently. The template package contains xml files and needs to be parsed into a given php array format.
I have come across two methods, namely the DOMDocument method and simple_load_file. personal preference. This is simple.
The usage is as follows:
$template_config_path = 'module_1.xml';function parseXMLConfig($template_config_path){$myxml = simplexml_load_file($template_config_path);return xmlToArray($myxml);}function xmlToArray($xml){$arr_xml = (array)$xml;foreach($arr_xml as $key=>$item){if(is_object($item) || is_array($item)){$arr_xml[$key] = xmlToArray($item);}}return $arr_xml;}$test = parseXMLConfig($template_config_path);print_r($test);
In fact, the DOMDocument method is to convert xml into a dom object and then perform related operations using the methods provided by dom, such as getElementById.