public function action_xmlread()
{
$xml = simplexml_load_file('new.xml');
foreach($xml->body as $b)
{
foreach ($b->node as $node) {
$this->dig($node);
}
}
}
public function dig($node)
{
if(isset($node->tit) && !isset($node->url))
{
$this->dig($node);
}else{
$this->grabData($node);
}
}
public function grabData($node)
{
$category_names = array('userdef1', 'userdef2');
$url = $node->url;
$category = '';
foreach($category_names as $catname)
{
if(isset($node->$catname))
{
$category = $node->$catname;
break;
}
}
$keywords = $node->key;
$title = $node->tit;
if(empty($url) && empty($category))
{
continue;
}
$this->saveItem($title, $url, $category, $keywords);
echo $url . " , category: ". $category;
echo '<br />';
}
当我运行 xmlread() 它死了:
已达到“100”的最大函数嵌套级别,正在中止!
在
$this->dig($node);
在 dig() 函数内部..如何解决?