标签:des io ar for on cti as tt type
/**
* node2array函数,将xml转换为数组
* @param object $node
*/
public function node2array($node){
$array = false;
if ($node->hasAttributes()){
foreach ($node->attributes as $attr){
$array[$attr->nodeName] = $attr->nodeValue;
}
}
if ($node->hasChildNodes()){
if ($node->childNodes->length == 1){
$array[$node->firstChild->nodeName] = $node->firstChild->nodeValue;
}else{
foreach ($node->childNodes as $childNode){
if ($childNode->nodeType != XML_TEXT_NODE){
if($childNode->childNodes->length == 1){
$array[$childNode->nodeName] = $childNode->firstChild->nodeValue;
}else{
$array[$childNode->nodeName][] = $this->node2array($childNode);
}
}
}
}
}
return $array;
}
php xml操作类DOMDocument xml转化为数组的函数
标签:des io ar for on cti as tt type
原文地址:http://www.cnblogs.com/lchecho/p/4095538.html