function ChangeAttrByName($name,$attr,$value) { return $this->_ChangeAttrByName($this->XMLTree,$name,$attr,$value); } function _ChangeAttrByName(&$tree,$name,$attr,$value) { if(is_array($tree->attribute)) { while(list($k,$v) = each($tree->atttibute)) { if($k == 'name' && $v == $name) { $tree->attribute[$attr] = $value; return true; } } } $total = count($tree->child); for($i = 0;$i<$total;$i++) { $result = $this->_ChangeAttrByName($tree->child[$i],$name,$attr,$value); if($result == true) break; } return $result; } //获取根节点 function GetDocumentElement() { return $this->XMLTree; } //遍历生成的xml树,重新生成xml文档 function WalkTree() { $this->TreeData = ''; $this->_WalkTree($this->XMLTree); return $this->TreeData; } //递归遍历 function _WalkTree($tree) { $this->TreeData .= '<'.$tree->TagName.' '; if(is_array($tree->attribute)) { while(list($key,$value) = each($tree->attribute)) { $this->TreeData .="$key=\"$value\" "; } } $this->TreeData .= '>'.$tree->data; $total = count($tree->child); for($i=0;$i<$total;$i++)
上一篇:PHP程序的常见漏洞攻击分析
下一篇:smarty实例教程
|