Skip to content

Fatal error: Uncaught Error: Call to undefined method DOMNodeList::getElementsByTagName() in index.php:4737 #410

Description

@jerrywham

If $node is not defined, getElementsByTagsName is undefined.
I propose this fix

    public static function getNodesName($node, $name)
    {
        if (strpos($name, ':') !== false) {
            list(, $localname) = explode(':', $name);
            $nodes = $node->getElementsByTagNameNS('*', $localname);
        } else {
        	if (isset($node->length)) {
            	$nodes = $node->getElementsByTagName($name);
        	} else {
        		$nodes = new stdClass();
        		$nodes->length = 0;
        	}
        }

        return self::filterNodeListByName($nodes, $name);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions