0
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 />';
}

When I run xmlread() it dies with:

Maximum function nesting level of '100' reached, aborting!

On the

$this->dig($node); 

Inside the dig() function.. How can this be solved?

Karem
  • 17,615
  • 72
  • 178
  • 278

2 Answers2

2

You are in infinite recursion, since you are not changing the parameter you are passing to dig. Maybe you have to pass the child nodes?

Maxim Krizhanovsky
  • 26,265
  • 5
  • 59
  • 89
  • Thats true, clicked for me now. I tried to change to $this->dig($node[0]) , but still the same errors. I did var_dump($node); exit; and got this: http://pastebin.com/dzcSsyv4 , I would like to grabData() on all the [0], [1] etc nodes inside the public 'node' => array as you can see.. Hope you can help me out thanks! – Karem May 09 '12 at 20:07
  • Update: I did this: http://pastebin.com/HXnvUyuL and now it works! Although my issue now is that I cant go deeper than one sub-node, which was my main purpose for making this script – Karem May 09 '12 at 20:11
  • Update: edited to $this->dig($n); Now it works how I wish i believe – Karem May 09 '12 at 20:14
1

To increase your function nesting level you need to edit your php.ini. But maybe your problem is somewhere else.

xdebug.max_nesting_level = 200

Source

Community
  • 1
  • 1
Abenil
  • 1,048
  • 3
  • 12
  • 26