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?

2 Answers 2

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?

Sign up to request clarification or add additional context in comments.

3 Comments

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: 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!
Update: I did this: 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
Update: edited to $this->dig($n); Now it works how I wish i believe
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.