I have this Code

```
function innerHTML($element) 
{ 
    $innerHTML = ''; 
    $children = $element -> childNodes; 
    foreach ((array)$children as $child) 
    { 
        $tmp_dom = new DOMDocument(); 
        $tmp_dom -> appendChild($tmp_dom -> importNode($child, true)); 
        $innerHTML .= trim($tmp_dom -> saveHTML()); 
    } 

    return $innerHTML; 
}

function DOMGet($html, $class, $num = 0, $type = "class")
{
    $dom = new DOMDocument('1.0', 'utf-8');
    @$dom -> loadHTML($html);
    $xpath = new DOMXPath($dom);
    $q = '//div[@'.$type.'="'.$class.'"]';

    if(is_numeric($num))
    {
        $arr = $xpath -> query($q);
        $arr = $arr -> item($num);

        return innerHTML($arr);
    }
    else if(strtoupper($num) == "ALL")
    {
        $arr = $xpath -> query($q);
        $abs = array();

        foreach($arr as $el) $abs[] = innerHTML($el);
        return $abs;

    }

    return false;
}

```

But it doesn't work at all, Sometimes when I try to call tag ( for example class="test" ) It doesn't show anything! Someone can Fix the code?