localhost1root123 smarty>
$doc = new DOMDocument('1.0','utf-8');
$doc->load("config.xml");
$roots=$doc->documentElement;//Get the root node which is config (only one)
$childs=$roots->childNodes;//Get all child nodes under the root node, which is db smarty
for($i=0;$i<$childs->length;$i++){ //Loop and store the number of child nodes under the root node into the array
$config_item=$childs->item($i); //Get db smarty specifically
$configs[$config_item->nodeName]=array();//Save the names of the two sub-nodes of db smarty into the array as data
$items=$config_item->childNodes; //Get all child nodes under db smarty
for($j=0;$j<$items->length;$j++){//Loop according to the number of all child nodes under db smarty and convert the name and value of the child nodes under db smarty into a two-dimensional array Deposit
$item=$items->item($j); //Get the child nodes under each db smarty through loop
$configs[$config_item->nodeName][$item->nodeName]=$item->nodeValue;
}//Writing of two-dimensional array
}
var_dump($configs);
http://www.bkjia.com/PHPjc/477693.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477693.htmlTechArticle?xml version=1.0 encoding=utf-8? configdbservicerlocalhost1/servicerrootroot/rootpw123/pw/dbsmarty/smarty/config ?php $doc = new DOMDocument(1.0,utf-8); $doc-load(config.xml); $root...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn